How to detect whether a file has been modified

cunny
Member Posts: 129
Hey guys,
just came up with a question, how to detect whether file has been modified after I open it and close it. I tried to use GETSTAMP but did not get it through.
Regards,
just came up with a question, how to detect whether file has been modified after I open it and close it. I tried to use GETSTAMP but did not get it through.
Regards,
0
Comments
-
when you open the file you can check the property DateLastModified, if this property is changed (OldDateLastModified <> ActualDateLastModified) before you close it, an other programm has modified it.
To check DateLastModified u can use WSH -> File.
RegardsDo you make it right, it works too!0 -
Hi garak,
Thanks very much. But I could not find such a function you mentioned, could you tell me a little more about it? By the way, what is WSH :-k
Regards,0 -
An example:
Name DataType Subtype Length WSHFSO Automation 'Windows Script Host Object Model'.FileSystemObject WSHFile Automation 'Windows Script Host Object Model'.File OldDate Date NewDate Date OldFileSize Integer NewFileSize Integer .... //here you open the file .... if isclear(WSHFSO) then create(WSHFSO); if WSHFSO.FileExists(ThePathAndTheFile) then begin WSHFile := WSHFSO.GetFile(ThePathAndTheFile); OldDate := WSHFile.DateLastModified(); OldSize := WSHFile.Size; end; ..... //here you read the file or what else in you C/AL is ..... //now you will check if the file is changed during your reading if WSHFSO.FileExists(ThePathAndTheFile) then begin WSHFile := WSHFSO.GetFile(ThePathAndTheFile); NewDate := WSHFile.DateLastModified(); NewSize := WSHFile.Size; end; clear(WSHFSO); if (OldDate <> NewDate) or (OldSize <> NewSize) then message('Somebody has change the file');
On the other hand, if you read the file with a File variable, and set before the property Writemode before you open it, no other program can change the file.
RegardsDo you make it right, it works too!0 -
[Topic moved from Navision forum to Navision Tips & Tricks forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi garak,
Perfect! Thank you very much =D> !
Regards,0 -
You're welcome,
so could you set the Attribute in your first post to Attribute: [Solved] (go to first post -> Button Edit -> Drop down Field in the header)
RegardsDo you make it right, it works too!0 -
Hi garak,
One more thing, the code works great but does not suit my requirement very well. What I want to do is when I open a file let's say a text and give some change, then I close it, at this moment, I need to check whether the text file has been modified or not. If yes I will have to tell the user about it and provide a function to replace the old one with the newest file. I have checked WSH to find some similar function but failed. Any idea?
Best Regards,0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions