locked
Code that will move one file into a folder? RRS feed

  • Question

  • I need a code that when you click on a button a file in the c:// drive will be moved into a folder into the C:/something/ drive? Thanks -civilwarrock
    Tuesday, May 4, 2010 1:24 PM

Answers

  • Try this (change the names accordingly):

        Dim sourceFile As String = "c:\somefile.txt"
        Dim targetFile As String = "x:\somefile.txt"
    
        Try
          My.Computer.FileSystem.MoveFile(sourceFile, targetFile, True)
        Catch ex As Exception
          MessageBox.Show("There was an error:" & vbCrLf & vbCrLf & ex.Message, _
                  "File Copy Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    • Proposed as answer by jinzai Tuesday, May 4, 2010 2:16 PM
    • Marked as answer by Alex Liang Tuesday, May 11, 2010 2:23 AM
    Tuesday, May 4, 2010 1:45 PM