Ok, 1 Problem. It addes the folder name to the files that are to be moved and doesn't move the files...
Heres a pic if you don't know what i'm saying...
Show me the exact code you used.
Originally Posted by Jason
Show me the exact code you used.
[php] Dim newDirectory As String = TextBox2.Text
For Each s As String In OpenFileDialog1.FileNames
Dim fileLoc As String = s
IO.File.Move(fileLoc, newDirectory & IO.Path.GetFileName(fileLoc))
Next[/php]
I had to use openfiledialog, buecause apperently, you can only use open for 1 thing.
Originally Posted by Cryptonic
[php] Dim newDirectory As String = TextBox2.Text
For Each s As String In OpenFileDialog1.FileNames
Dim fileLoc As String = s
IO.File.Move(fileLoc, newDirectory & IO.Path.GetFileName(fileLoc))
Next[/php]
I had to use openfiledialog, buecause apperently, you can only use open for 1 thing.
What was in TextBox2?
Originally Posted by Jason
What was in TextBox2?
The folder location...
Originally Posted by Cryptonic
The folder location...
. I need to know exactly what was in it. Because I tested the code I provided and it worked fine, so I'm guessing it has something to do with the filelocation.
Originally Posted by Jason
. I need to know exactly what was in it. Because I tested the code I provided and it worked fine, so I'm guessing it has something to do with the filelocation.
Its a FolderBrowserDialog and I have a New folder on my desktop and in that folder are 2 files (like in the picture) and theres a folder in that, so i select my 2 files. I put the folder location in the Folder.
Originally Posted by Cryptonic
Its a FolderBrowserDialog and I have a New folder on my desktop and in that folder are 2 files (like in the picture) and theres a folder in that, so i select my 2 files. I put the folder location in the Folder.
Stop answering a question with a general statement and just answer it as I asked it.
What was the contents of TextBox2 at the time when you wanted to move the files?
I don't want anything apart from a straight answer, otherwise I can't help you.
Maybe a missing \?
Ok... well i'll post a pic then...
and in the txtbox
C:\Users\My Username\Desktop\New folder\Folder
Originally Posted by Cryptonic
Ok... well i'll post a pic then...
and in the txtbox
C:\Users\My Username\Desktop\New folder\Folder
Okay try this then:
Code:
Dim newDirectory As String = TextBox2.Text
For each s As String in OpenFile.FileNames
Dim fileLoc As String = s
IO.File.Move(fileLoc, IO.Path.Combine(newDirectory, IO.Path.GetFileName(fileLoc)))
Next
Originally Posted by Jason
Dim newDirectory As String = TextBox2.Text
For each s As String in OpenFile.FileNames
Dim fileLoc As String = s
IO.File.Move(fileLoc, IO.Path.Combine(newDirectory, IO.Path.GetFileName(fileLoc)))
Next
Thanks, it works. I guess thats all.
Originally Posted by Cryptonic
Thanks, it works. I guess thats all.
TextBox2.Text was missing the final backslash so when i concatenated the strings, the was no backslash to delimit the file and the folder so it just clumped together. IO.Path.Combine can handle both types of string so I used that instead.