tags:

views:

80

answers:

1

I'm trying to create an installer like application. Here is what its supposed to do: create a directory in C: and name it batch. Then copy the files from the folder and move it to the C:\batch directory. But the copying of files doesn't work. How am I supposed to put the exact directory in here if that exact directory does not apply to all.What do I do with it. If the file that is to be copied is from: E:\Documents and Settings\Rew\My Documents\Visual Studio 2008\Projects\batch\batch

I want it to be universal. So that wherever the file maybe it could always copy it regardless of where it is located.

Somehow the creating of a directory work. Dim FileToCopy As String Dim NewCopy As String Try Directory.CreateDirectory("C:\Batch")

            FileToCopy = "\batch\batch\ipconfigrenew.bat"
            FileToCopy = "\batch\batch\ipconfigrelease.bat"
            FileToCopy = "\batch\batch\ipconfigflushdns.bat"
            NewCopy = "C:\Batch"

            If System.IO.File.Exists(FileToCopy) = True Then
                System.IO.File.Copy(FileToCopy, NewCopy)
                MsgBox("File Copied")
            End If
        Catch
        End Try
        MsgBox("Done")
+1  A: 
  • First the only value in FileToCopy by the time you do the copy is the last one. I'm having trouble parsing the question to figure our what you need but I would first do this

    Dim FileToCopy(3) As String
    FileToCopy(0) = "\batch\batch\ipconfigrenew.bat"
    FileToCopy(1) = "\batch\batch\ipconfigrelease.bat"
    FileToCopy(2) = "\batch\batch\ipconfigflushdns.bat"
    Dim NewCopy As String = "C:\Batch"
    Dim s As String
    For Each s In FileToCopy
        If System.IO.File.Exists(s) = True Then
            System.IO.File.Copy(s, NewCopy)
            MsgBox("File Copied")
        End If
    Next
    

Next I would decide if I needed to write this in a more generic way.

rerun