Fix corrupted txt file (NULL)
After a sudden power outage I found that a couple of my files that were opened with Notepadd++ (Win 10) were corrupted as follows:
I tried many things to open it without any luck, of the thing I tried:
- check to see if there were a previous versions in the file properties (none)
- tried some recovery software, but all just find deleted files
- tried opening the file with other software (Winword, Wordpad, Chrome, Notepad, Safari, Firefox…)
- the backup option was not selected by default in NP++, so no backups
- tried to open the file in Word using the “recover any file tool” - blank
- no hidden files in the folder
The files opens with white spaces (blank) in some software, and shows “NULL characters” in NP++. And when trying to compress the file (8MN, it becomes like 8kb).
Any suggestions are much appreciated.
I’m a happy camper now. for past few hours I had the exact same problem but finally after a deep research I found this article for the about puzzle please visit the below one :https://superuser.com/questions/377904/recover-file-corrupted-due-to-power-cut-off
An year ago issue is still persistent!
I was a big fan of this software but now after loosing some 20+ hours of work, I am devastated! Even the saved file is being NULLed! I googled another 2 hrs trying to find any help! What a waste… lesson learned…
I realize my mistake :(
Should have stuck with just notepad or any other editor!
Good bye Notepad++
So, seemingly, in some circumstances, on saving a file, N++ would just save corrupted contents, with NUL bytes, in the present version, on the HD ? Now, the problem is to find out in which circumstances this issue occurs ?!
May be, @claudia-frank and @pnedev, the part of code to examine is just when N++ is saving current file ? Indeed, as said above, after reading file and before saving it, N++, certainly, doesn’t interfere with current modified file on hard disk, if NO backup process, either, from within N++ or from outside, is presently running in the background !
May be, working with a new # tab, instead of a previously saved file, could be of importance, too ?
Some thoughts, from a non-coder ( at least in C/C++ ! ) guy !
I had the same issue today morning starting Notepad++ 7.5.4 32 bit version, on Win 10 x64. I had no other choice just to force power off my laptop due USB problems yesterday evening. All the previously opened files/tabs closed/disappeared, and the one edited last time (not saved explicitly) corrupted. Notepad++ works the following way for my by default without any specific settings: Notepad++ is keeping the content of modified text files without saving them when closing the app. Next time I reopen NotePad++, I have the insaved contect kept without any specific settings. If I open text files with ms notepad the unsaved content in notepad++ is not visible there. In this case however the corrupted file is also corrupted in other editors.
I’ve had this issue with corrupted files for at least a dozen times in the last 1-2 years. As far as I remember, I’ve always been able to restore the file from the “backups” folder.
But just today I’ve had it again (blue screen of Windows after some weird bugs in Android emulator, whatever) - and the “backups” of Notepad++ folder seems to have NOT been saving anything for quite a while! E.g. of the file which was corrupted (all "NULL"s) the backup copy is dated June 2017. That is, no backup of it was done in 9 months, although I was editing that file multiple times per day, every day in the last several years!
In the “backups” folder I do see some backup files, but the dates of them are scattered quite randomly and scarcely (like, 1 backup file per month). I know I’ve been editing tons of different txt files in the last months, but apparently almost none of that was backed up!
I now went ahead and set Setting->Preferences->Backup on save, Verbose Backup. Now if I try to edit some txt file and save it, nothing is created in “backups” folder. And no backups are made every 7 seconds, as the other setting says. So, apparently, both settings don’t work.
So, 2 things:
how is it even possible that the whole file would turn into NULLs if there is a power outage/blue screen and the whole Windows OS just crashes? Why on Earth is Notepad++ writing anything into the file at that point? I suppose the normal way a text editor would operate is to edit the copy of the contents of the file in RAM and only flush the contents into the actual file when you hit Save. My files are pretty small (below 1MB, even below 100KB mostly), so why would there be a need to write directly onto the disk? Still, if Windows is crashing, how does Notepad++ get a chance to save anything on disk…
the whole backups system is completely bugged now, and no backups are done no matter what the settings are.
Fortunately I do have backups of my own on Dropbox, but for the file in question the backup is 1 month old, so I will still lose quite some work, though not everything…
Frankly, this whole situation is ridiculous. It really is. I haven’t seen any editor which would not only lose recent work but instead devastate the whole file which could mean years of work.
I’m on Windows 7 64 bit, Notepad++ 7.5.4 (latest version).
I feel your pain–actually I felt it only once and I didn’t lose much (only about 2 hours of work)–but still… It is a known issue, at least to posters here on this forum–see my list of links in this thread–but I don’t know that it is getting much if any attention from developers.
There is a theory (not mine…but I can’t prove/disprove it) that having one of the backup methods turned ON causes or contributes to the chain of events that allows this data loss to occur. I know that when it happened to me (via a hardware-related BSOD) that I did indeed have Verbose backups enabled and backups were being made right up until the time of crash. Unfortunately, my experience was that all files I had changed and saved during that particular Notepad++ editing session (2 hours old) were wiped out, including all backups made during that time.
I always had my own backup plan in place, entirely separate from Notepad++'s control, which is why I didn’t lose a lot. I recommend everyone do the same…even after this issue is resolved!
At one point last month, I tried using the windows API from an external process to try to kill the Notepad++ instance, and see if I could reliably replicate the issue, but I couldn’t get it to trigger; apparently, even killing the process externally is too “clean” of an exit.
Today, I began to think that maybe there was a way to force a Windows Blue Screen Of Death while running NPP, and see if it could replicate the problem – my thought was in a Virtual Machine, to protect any actual hardware.
I found this MS TechNet post which explains how to initiate a BSOD. It has a disclaimer, “you cannot manually initiate a Stop error on a virtual machine that has virtual machine extensions installed”, but that implies that a VM without extensions installed should be able to be forced to BSOD.
I don’t have a VM (or a physical machine that I could risk), nor do I have the windows-app debugging skill necessary to figure out what’s going wrong, even if I could replicate the problem reliably… but I thought I’d share the idea, in case someone else has the right tools and skillset.
(I posted this almost verbatim in the GitHub issue #2381, but thought I’d share it here, too.)
Right after the issue happened to me, I tried manually forcing some BSODs on an old machine (running Windows 7) that I don’t care so much about. I had no luck in replicating the NUL corruption thing that way, even though I was careful in my attempt to set up the exact Notepad++ configuration I had been running (fairly easy as I use the “portable” version). As my original BSOD was “hardware-related”, I couldn’t duplicate that part in the recreation…
So I like your thinking, but no-dice for me when I tried it a bit ago…
Just today I found out that Dropbox (even the free account of it) saves versions of files, so it kind of acts like a version control system (e.g. SVN), but you don’t have to do manual commits - any time you save the file, Dropbox stores another version of the file. I suppose on the backend they have some SVN-like implementation of this functionality (saving only the changes), but to the user it just looks like separate, chronologically listed versions of the file. Even if Dropbox doesn’t keep the versions for long, or has a limit on the combined size of all the versions, it’s still an excellent defense vs these sudden power outages or blue screens. Because after the computer restart one surely will still have the few copies just before the outage in Dropbox (plus the last NULL-filled copy).
So, yeah, setting Dropbox to start together with Windows is important then.
And btw one doesn’t even have to keep all the important files in the Dropbox folder. Instead, one can create a “junction” for the most important files or folders (https://www.dropboxwiki.com/tips-and-tricks/sync-other-folders).
Lesson learnt :)
Oh my, just found out that setting “Verbose backup” in Notepad++ now creates a folder named “nppBackup” at the same place as the txt file and saves the backups there each time you save. If you don’t want to clog your folders with all these multiple nppBackup subfolders, you can set a custom path where all the backups of all edited files will be saved, e.g. some folder inside Dropbox.
Alessandro Lo Cuoco
It seems that when data is apparently replaced by null characters information is not actually lost. I searched on the web and I found that using a file recovery application (Recuva) one can still obtain the original file without any loss of information (I tried this myself). This is very strange, as it’s not clear where this information come from if the “null” characters are really “null”…
See https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/CMakeLists.txt and https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/gcc
for cross compilation. Open PRs needed:
thank you but since installing VS2017 in my VM it is good enough.
It does take <1 minute to do a full clean compile of npp, scintilla and python script plugin
and ~15-20 seconds for code changes to test.
In my case, file size is showing 7kb and unable to find that file in back up folder. When I open it shows Null in Notepad++, empty in Notepad.
I tried Recuva and restore the file, again context is not readable.
Restore previous version is also not available. I’m using Windows 10 64 bit OS
Please help me to recover file
I fixed a corrupted file using the deep scan feature of Recuva.
for anyone still looking for this!
right click on the file -> properties -> previous versions, -> open, …
check contents before you hit restore.
saved 7 days of work!!!