Hi,
I want to include a function in my program that involves my copying files from my cd drive D:/ to my hard drive C:/.
The code I'm using is below but it isn't working. The first one came up with an error, and the second one didn't come up with an error but didn't copy the files, I've searched round the internet but can't find anything.
vb.net Code:
My.Computer.FileSystem.CopyFile(foundFile, destPath & foundFile, True)
Dim srcPath As String
Dim destPath As String
srcPath = ComboBox1.Text & "Web Browser"
destPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
My.Computer.FileSystem.CopyDirectory(srcPath, destPath, True)
Dim srcPath As String
Dim destPath As String
srcPath = ComboBox1.Text & "Web Browser"
destPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
' set the current directory to the source
My.Computer.FileSystem.CurrentDirectory = srcPath
' loop through the files in the directory
For Each foundFile As String In My.Computer.FileSystem.GetFiles _
(My.Computer.FileSystem.CurrentDirectory)
' strip off the directory
foundFile = Microsoft.VisualBasic.Right(foundFile, Len(foundFile) - 3)
' check for .bmp extension
If Microsoft.VisualBasic.Right(foundFile, 4) = ".bmp" Then
' copy the file
My.Computer.FileSystem.CopyFile(foundFile, destPath & foundFile, True)
End If
Next
The combo box allows the user to select which drive the cd is in, incase you were wondering.
Can anyone help?
Thanks,
m1la