Copy file

  • Thread starter Thread starter Leszek
  • Start date Start date
L

Leszek

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
 
well you could do it this way

Dim strfiles() as String = Io.Directory.GetFiles("C:\SomeDirectory")

Dim fs as New IO.FileStream("C:\LogFile.txt", IO.FileMode.Create,
IO.FileAccess.Write)

Dim sw as New IO.StreamWriter(fs)

try

for each str as String in strFiles

File.Copy(str, "C:\DestinationDirectory")

sw.WriteLine("Some log stuff here")

next

catch ex as exception

MsgBox(ex.Message)

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
 
Back
Top