Results 1 to 7 of 7

Thread: I need code to create a directory, and copy files from one drive to another drive.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    I am trying to find out if a batch file can be created using VB. One that will autorun(optional), create a directory on the c:\ drive, copy files from the cd-rom drive to the newly created directory on the c:/.

    If this is possible, can you please help me come up with the code. I have never created a batch program before.

    Thanks in advance


  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    Hutchie,

    I don't know!! My boss just told me to research if the batch could be done in VB. What I wrote in my first request was all I got from her. She is out of the office this week and I can't ask her about it.

    I would make a guess and say that the application is going to be installed on the user's machine.

    Can you help either way?

    Thanks Marita_l

  3. #3
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26

    Post

    Yes !,

    Here is some code that you could use to create a folder on the C:\, goto the CD find the correct CD and copy the files from it to your newly created folder :.
    You might need to put some error trapping in regarding not finding the CD at all though,

    If you need any help let me know,
    Option Explicit
    Dim oFile2 As TextStream
    Dim oFile As New FileSystemObject

    Private Sub Form_Load()
    If oFile.FolderExists("C:\Your Folder Name") Then
    ' Either delete or move it !
    Else
    oFile.CreateFolder ("C:\Your Folder Name")
    GetCDfiles ' Find CD
    ' go to new sub to do what you need to do after the copy of the files to the H/Drive
    End If
    End
    End Sub

    Sub GetCDfiles()
    Dim iCdstr
    Dim oFile2 As Object
    On Error Resume Next
    For iCdstr = 100 To 122
    Set oFile2 = oFso.GetDrive(Chr(iCdstr))
    If oFile2.DriveType = 4 Then ' If this is a Cd Drive
    If oFso.FileExists((oFile) & "\The CD Folder\Your file.Extension") Then ' Check one of your files exists on the cd
    oFile.CopyFile (oFile) & ("\The CD Folder\The File you want to copy.extension"), ("C:\Your Folder Name\Your File.Extension"), True ' Copy the file you want to your
    oFile.CopyFile (oFile) & ("\The CD Folder\The File you want to copy.extension"), ("C:\Your Folder Name\Your File.Extension"), True ' to the folder you created
    oFile.CopyFile (oFile) & ("\The CD Folder\The File you want to copy.extension"), ("C:\Your Folder Name\Your File.Extension"), True
    Exit Sub
    End If
    End If
    Next
    End Sub

    Hutchie.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    Hutchie,


    Thank you very much! This looks like it will work.

    Very Appreciative

    Marita_l

  5. #5
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26

    Post

    Why don't you just get VB to create the new directory and copy the files from the CD into it ?.

    If you need some code to do this let me know and I'll put something together for you.

    Hutchie

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    I need to incorporate it into the cd. This will be used over and over on other PC installs.

    Thanks again

  7. #7
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26

    Post

    Are you going to be installing your app onto the users machine's ?.
    If you are the code will be different than just running the app from the CD.


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