Article View: borland.public.cppbuilder.nativeapi
Article #5807DeleteFile() returns before the file is deleted?
From: Dennis Jones
Date: Mon, 04 Jul 2005 04:13
Date: Mon, 04 Jul 2005 04:13
27 lines
2306 bytes
2306 bytes
Hi, I have a situation in which I watch for and process files as they are created in a certain folder. I do this in a thread using FindFirstChangeNotification (and FILE_NOTIFY_CHANGE_FILE_NAME) which seems to work fine. When my thread is awakened by the existence of a new file, I use FindFirstFile/FindNextFile to get a list of all files matching my filespec, sort them by creation time, and then process them one by one. After processing a file, I delete it because I do not want it to get processed again. Deleting the file causes another change notification to be sent to my application which results in another pass through the FindFirstFile/FindNextFile loop, which (quite surprisingly!) discovers the file again, even though it was supposedly deleted!! The only thing that makes any sense is that DeleteFile() must be returning before the file system has actually deleted the file. Is this really the case? (caching maybe?) Now, I can use FILE_NOTIFY_CHANGE_LAST_WRITE as the NotifyFilter instead of FILE_NOTIFY_CHANGE_FILE_NAME, and that still gives me notifications for new files and does not give me the additional notifications for deleted files, which is even better. So while my intention is to use FILE_NOTIFY_CHANGE_LAST_WRITE instead (since it would seem to be more efficient, resulting in a 50% reduction in thread awakenings), I am still curious about the delay in files getting deleted when calling DeleteFile(). - Dennis
Technical Details
Message-ID:
<42c8b764@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c3568423d186a70,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dennis Jones" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: DeleteFile() returns before the file is deleted? Date: Sun, 3 Jul 2005 21:13:14 -0700 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 204.200.27.7 Message-ID: <42c8b764@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1120450404 204.200.27.7 (3 Jul 2005 21:13:24 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail