Home All Groups Group Topic Archive Search About
Author
11 Jul 2006 11:59 AM
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

Author
11 Jul 2006 1:24 PM
iwdu15
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

--
-iwdu15
Author
11 Jul 2006 2:13 PM
Leszek
Thanks!

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

Show quoteHide quote
U¿ytkownik "iwdu15" <jmmgoalsteratyahoodotcom> napisa³ w wiadomo¶ci
news:114BC31F-3A02-4312-AD72-29AA708605B7@microsoft.com...
> 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
>
> --
> -iwdu15