Copy file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leszek

    #1

    Copy file

    Hello!

    I have a folder with few big files (about 1GB). I would like to copy them to
    other folder. But "one after one".
    How can I now, that first copy of first file ended? I would like to run my
    special event (like writing to the eventlog) and then start to copying
    second file.

    Leszek


  • iwdu15

    #2
    RE: Copy file

    well you could do it this way

    Dim strfiles() as String = Io.Directory.Ge tFiles("C:\Some Directory")

    Dim fs as New IO.FileStream(" C:\LogFile.txt" , IO.FileMode.Cre ate,
    IO.FileAccess.W rite)

    Dim sw as New IO.StreamWriter (fs)

    try

    for each str as String in strFiles

    File.Copy(str, "C:\Destination Directory")

    sw.WriteLine("S ome log stuff here")

    next

    catch ex as exception

    MsgBox(ex.Messa ge)

    Finally

    sw.flush()
    sw.close
    fs.close()

    end try


    which will copy all files in a given directory and write a log file after
    each one....hope this is what you meant

    --
    -iwdu15

    Comment

    • Leszek

      #3
      Re: Copy file

      Thanks!

      I didn't try, that file.copy is waiting to finish copying file.

      U¿ytkownik "iwdu15" <jmmgoalsteraty ahoodotcomnapis a³ w wiadomo¶ci
      news:114BC31F-3A02-4312-AD72-29AA708605B7@mi crosoft.com...
      well you could do it this way
      >
      Dim strfiles() as String = Io.Directory.Ge tFiles("C:\Some Directory")
      >
      Dim fs as New IO.FileStream(" C:\LogFile.txt" , IO.FileMode.Cre ate,
      IO.FileAccess.W rite)
      >
      Dim sw as New IO.StreamWriter (fs)
      >
      try
      >
      for each str as String in strFiles
      >
      File.Copy(str, "C:\Destination Directory")
      >
      sw.WriteLine("S ome log stuff here")
      >
      next
      >
      catch ex as exception
      >
      MsgBox(ex.Messa ge)
      >
      Finally
      >
      sw.flush()
      sw.close
      fs.close()
      >
      end try
      >
      >
      which will copy all files in a given directory and write a log file after
      each one....hope this is what you meant
      >
      --
      -iwdu15

      Comment

      Working...