Results 1 to 4 of 4

Thread: Copying Directorys

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2009
    Posts
    31

    Cool Copying Directorys

    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:
    1. My.Computer.FileSystem.CopyFile(foundFile, destPath & foundFile, True)
    2. Dim srcPath As String
    3.         Dim destPath As String
    4.         srcPath = ComboBox1.Text & "Web Browser"
    5.         destPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
    6.        My.Computer.FileSystem.CopyDirectory(srcPath, destPath, True)
    7.  
    8. Dim srcPath As String
    9.         Dim destPath As String
    10.         srcPath = ComboBox1.Text & "Web Browser"
    11.         destPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)
    12.         ' set the current directory to the source
    13.         My.Computer.FileSystem.CurrentDirectory = srcPath
    14.         ' loop through the files in the directory
    15.         For Each foundFile As String In My.Computer.FileSystem.GetFiles _
    16.         (My.Computer.FileSystem.CurrentDirectory)
    17.             ' strip off the directory    
    18.             foundFile = Microsoft.VisualBasic.Right(foundFile, Len(foundFile) - 3)
    19.             ' check for .bmp extension    
    20.             If Microsoft.VisualBasic.Right(foundFile, 4) = ".bmp" Then
    21.                 ' copy the file        
    22.                 My.Computer.FileSystem.CopyFile(foundFile, destPath & foundFile, True)
    23.             End If
    24.         Next
    The combo box allows the user to select which drive the cd is in, incase you were wondering.

    Can anyone help?

    Thanks,

    m1la
    Last edited by m1la; Apr 18th, 2010 at 01:59 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width