On 21-Apr-07, at 9:33 AM, Jim Wagner wrote: > Greetings NUG - > > I have a file that I need to "update". Think preferences, though its > not. I can think of several ways to do it and I am unclear about the > tradeoffs. The contents of the file are all cached within the app. It > is a text file, probably less than 100k in size. > > 1. Delete the old file, and write a new one with the same name. This, > however, would not appear to maintain the creation date. I think I > remember problems about the old file not being deleted if you tried to > create the new one too quickly. > > 2. Create a new file with a different name, then change file names and > delete the old one. This also raises the question about maintaining > the > creation date.
If you use either of these look into Charles Yeomans code for swapping files. This is an OS level "swap" and happens atomically so you are less likely to run into problems. It also preserves the file attributes (if I recall correctly) > 3. Appending to the existing file does not appear to do what I need. > > 4. BinaryStream appears to be able to write selectively, but its not > clear how to do it. To move "back to the beginning of the file you set the position to 0. Setting the position to a value moves where you are going to write to that position in the file > Reviewing the FolderItem class, it does appear that the creation date > can be read and written, though its not clear whether or not that > includes time. This would appear to make the first two options viable. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
