|
-
May 20th, 2013, 06:13 AM
#1
When saving file and the power lost file is lost too?
I know that is not good practice to 'pull the power' but this is what happens in pubs,
I have jukebox software that saves to a file, now if the file is saved and then the power is lost (say within 15 seconds or so) when I then open the file in notepad (after reboot) the file is full of blank chrs of the length that it should be.
I imagine that this has something to do with write caching, but i have turned it off for the drive that is in question.
Also if I quickly open the file in notepad before the hard power off I can see all of the data before the power loss.
Whats happening here? and how do I get around it?
Thanks,
Kris
-
May 20th, 2013, 07:14 AM
#2
Re: When saving file and the power lost file is lost too?
You can specify FileOptions with a FileStream object, a couple of the constructors take the FileOptions as an argument.
The FileOptions is an enumeration and one if its values are WriteThrough which indicate that the system should write the file directly and not use any intermediate cache.
-
May 20th, 2013, 09:25 AM
#3
Re: When saving file and the power lost file is lost too?
 Originally Posted by Joacim Andersson
You can specify FileOptions with a FileStream object, a couple of the constructors take the FileOptions as an argument.
The FileOptions is an enumeration and one if its values are WriteThrough which indicate that the system should write the file directly and not use any intermediate cache.
I doubt this would work. But it's hard to tell anything without doing a real test, since the OP has indicated that he can see the file contents if he opens the file in notepad just before the power loss.
-
May 20th, 2013, 09:29 AM
#4
Re: When saving file and the power lost file is lost too?
Of course he will see the content if he opens it up in another application. If the content is cached it will be taken from the cache instead of from the disk.
-
May 20th, 2013, 10:22 AM
#5
Re: When saving file and the power lost file is lost too?
Isn't the real question about why is the file corrupted? If you have the file open but are not manipulating it and the power goes out why is it corrupted?
@i00 - they have changed the rate this post icon, so the reference to scales in your signature is out of date.
-
May 20th, 2013, 10:51 AM
#6
Re: When saving file and the power lost file is lost too?
A file that you just saved to disk might not actually be written back to disk immediately. Windows may cache the changes to a file and write these changes back at a later time (normally Windows empties all its caches after 15 minutes if no user interaction has occurred, or earlier if you have power saving settings that take effect before that). So if you suddenly lose power, even just after you have just saved the file the file may become corrupted since the data wasn't actually written back to disk. This is the normal behaviour of Windows and is used to save both power and make the OS run faster.
-
May 20th, 2013, 07:10 PM
#7
Re: When saving file and the power lost file is lost too?
 Originally Posted by Joacim Andersson
You can specify FileOptions with a FileStream object, a couple of the constructors take the FileOptions as an argument.
The FileOptions is an enumeration and one if its values are WriteThrough which indicate that the system should write the file directly and not use any intermediate cache.
Thanks for the suggestion ... I will try this when I get home; am still a little surprised that this happens in the first place since I said in my OP that I have disabled write caching... but anyway...
Will let you know how it goes *fingers crossed*
Kris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|