Hello,
I'm trying to get Vb.net to move a file selected from an openfiledialog.
This is what I have so far:
Dim FileToMove As String
Dim MoveLocation As String
FileToMove = openFD.FileName
MoveLocation = folderbrowser.SelectedPath
If System.IO.File.Exists(FileToMove) = True Then
System.IO.File.Move(FileToMove, MoveLocation)
MsgBox("File Moved")
End If
What I need to do is cut out just the file name from the openFD.FileName from the rest of the path, and attach it to the SelectedPath so I can move the file. What do I need to do?
Thanks,
AW
Trying to move file
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

PJ MartinsRank #2,548 · 548 reputationPosted Jun 29, 2010, 5:12 PM EDT
Dim finf as new FileInfo(FileToMove)
System.IO.File.Move(FileToMove, MoveLocation & "\" & finf.Name)
Anatole8 reputationPosted Jun 30, 2010, 4:08 AM EDT
I put in that, but I get an error - type Fileinfo isn't defined. I'm running VB 2003. Do I have to add a reference?
Anatole8 reputationPosted Jun 30, 2010, 5:34 AM EDT
CrishRank #1,486 · 1.1K reputationPosted Nov 29, 2010, 9:06 PM EST