Click here to Skip to main content
15,898,222 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionV2.0 vs V3.0 Pin
Ray Cassick20-May-07 10:36
Ray Cassick20-May-07 10:36 
AnswerRe: V2.0 vs V3.0 Pin
Christian Graus20-May-07 11:03
protectorChristian Graus20-May-07 11:03 
GeneralRe: V2.0 vs V3.0 Pin
Ray Cassick20-May-07 11:15
Ray Cassick20-May-07 11:15 
GeneralRe: V2.0 vs V3.0 Pin
Christian Graus20-May-07 12:59
protectorChristian Graus20-May-07 12:59 
QuestionAdo.net with WPF (.Net Framework 3.0) xaml browser application Pin
Nada Adel19-May-07 7:23
Nada Adel19-May-07 7:23 
AnswerRe: Ado.net with WPF (.Net Framework 3.0) xaml browser application Pin
Paul Conrad14-Jul-07 6:52
professionalPaul Conrad14-Jul-07 6:52 
QuestionDetecting if a folder is being copied to... Pin
Christoff91517-May-07 11:17
Christoff91517-May-07 11:17 
AnswerRe: Detecting if a folder is being copied to... Pin
Dave Kreskowiak17-May-07 11:33
mveDave Kreskowiak17-May-07 11:33 
Christoff915 wrote:
So far I've tried checking the LastWriteTime and LastAccessTime of the directory via the DirectoryInfo class. For some reason, these properties would state that the last write and access times were x seconds ago, even when the files were not completely done copying.


This is true. The reason is because NTFS only updates those properties every once in while. It does NOT do it on-the-fly as the file is being written to. So, the file WAS written to at that time. It doesn't mean that the file write has stopped yet.


Christoff915 wrote:
I thought this might be caused by files being written to subfolders inside the folder I was checking (which I'm assuming are not checked in reference to that particular top folder), so on a suggestion from Christian Graus, I tried a recursive script that would get the size of all files and folders inside the target folder and return that value. My program would use this method to first get the size of the folder, sleep the thread for a second, then recheck the value. If the values matched, the folder would be processed. If they didn't match, the folder was passed over and checked on the next cycle. However, even though the files were still not done copying (the file copy progress box was still showing), the cumulative directory size would be reported as the same on both checks and it would pick up the folder early again. I also checked the reported size value against the actual size of the folder (though the properties window in Windows) and the reported size matched the actual directory size, even though my program got that value while the files were still actively copying (once again, the file copy progress dialog was still visible and progressing).


Again, you're checking this information faster than NTFS updates it! NTFS is LAZY. You cannot depend on the properties to tell you when the folder is finished.

You can't check this every second to see if it's done. You're simply not going to know unless the application that is writing the data tells you. Somehow, I doubt that it has any such capability.

Since the app can't tell you when it's done, you're only semi-reliable method is to check for the existance of the folder and get it's total size, about once every 15 seconds, and KEEP DOING THIS! If the size doesn't change for, say, the last 3 passes, then you can assume the app is done writing to the folder.

Note, I said "assume". Because of system failures or loads, or whatnot, there is no absolutely 100% reliable method of knowing when the other app is done. THe only way that's going to happen is if the other app tells you it's done.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Detecting if a folder is being copied to... Pin
Christoff91517-May-07 13:48
Christoff91517-May-07 13:48 
AnswerRe: Detecting if a folder is being copied to... Pin
kubben18-May-07 5:58
kubben18-May-07 5:58 
GeneralRe: Detecting if a folder is being copied to... Pin
Dave Kreskowiak18-May-07 9:58
mveDave Kreskowiak18-May-07 9:58 
GeneralRe: Detecting if a folder is being copied to... Pin
kubben18-May-07 11:50
kubben18-May-07 11:50 
GeneralRe: Detecting if a folder is being copied to... Pin
Christoff91518-May-07 12:16
Christoff91518-May-07 12:16 
GeneralRe: Detecting if a folder is being copied to... Pin
Dave Kreskowiak18-May-07 12:54
mveDave Kreskowiak18-May-07 12:54 
AnswerRe: Detecting if a folder is being copied to... Pin
Vasudevan Deepak Kumar23-May-07 4:32
Vasudevan Deepak Kumar23-May-07 4:32 
QuestionDoubt on Serialization Pin
meeram39517-May-07 3:18
meeram39517-May-07 3:18 
AnswerRe: Doubt on Serialization Pin
kubben17-May-07 6:14
kubben17-May-07 6:14 
AnswerRe: Doubt on Serialization Pin
Not Active17-May-07 8:00
mentorNot Active17-May-07 8:00 
AnswerRe: Doubt on Serialization Pin
Scott Dorman19-May-07 5:24
professionalScott Dorman19-May-07 5:24 
AnswerRe: Doubt on Serialization Pin
GgAben22-May-07 0:24
GgAben22-May-07 0:24 
Question.NET Enterprise Library Pin
Bommannan.Ramalingam16-May-07 22:50
Bommannan.Ramalingam16-May-07 22:50 
AnswerRe: .NET Enterprise Library Pin
Not Active17-May-07 8:07
mentorNot Active17-May-07 8:07 
QuestionPrinters in WPF Pin
jjholt16-May-07 14:32
jjholt16-May-07 14:32 
AnswerRe: Printers in WPF Pin
Paul Conrad14-Jul-07 6:51
professionalPaul Conrad14-Jul-07 6:51 
GeneralRe: Printers in WPF Pin
jjholt16-Jul-07 16:37
jjholt16-Jul-07 16:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.