Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using FileSystem.DeleteFile, FileSystem.createFile, and FileSystem.CopyFile. Can someone tell me how to know when the process is complete? I am delete file faster than my code can keep up. So i want to know how can i tell if the process of deleting a file for example is done.

---------------
the below if statement will return true (sometime when the file does not exist). As a result of it returning true while the file does not exist i get an error. Is there a better way to determine when i delete the file ?

VB
If System.IO.File.Exists(FILE_NameCopy) = True Then
         My.Computer.FileSystem.DeleteFile(FILE_NameCopy)
         
     End If
Posted
Updated 16-Oct-13 6:10am
v5

1 solution

The event-oriented approach does not look like some code is "telling" you what happened. The technology is much better: you use event handlers to handle events. Please see:
http://msdn.microsoft.com/en-us/library/ms973905.aspx[^].

Now, how to handle the events you are interested in? This is done using the class System.IO.FileSystemWatcher:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].

However, be aware of some problems. Please see these CodeProject articles:
FileSystemWatcher - Pure Chaos (Part 1 of 2)[^],
FileSystemWatcher - Pure Chaos (Part 2 of 2)[^].

—SA
 
Share this answer
 
Comments
Kenneth Haugland 16-Oct-13 12:30pm    
5'ed. It is truly amazing what one can find on this site :-)
Sergey Alexandrovich Kryukov 16-Oct-13 12:53pm    
Agree. Thank you, Kenneth.
—SA
Member 8525993 17-Oct-13 9:37am    
Thank you so much. you totally answer my question!!!


but the problem i was having had to do with dropbox. when i delete or create a file dropbox would sync it. while dropbox was syncing it had permession/control over text file result in an error. Once i moved it out of my dropbox it worked fine ...
Sergey Alexandrovich Kryukov 17-Oct-13 10:56am    
You are welcome.
I don't really understand what is your drop box and what's the problem. Perhaps you need to ask a separate question.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900