RWPT – My Day Ruining Maneuver


So here is a nice little tip that is a direct result of sleep deprivation and bad habit. 


I was working on some C# code that grabs some log files and wraps them up into a cab file and moves them off to a different location.  After that it clears the directory so new logs can be written.  In writing the code I figured I would take the liberty of trying to get everything in the folder deleted except for the tool itself. 


So in thinking I did this:


 —snip—


Directory.Delete(Directory.GetCurrentDirectory(), true);


—end— 


Where Directory refers to System.IO.Directory


So I am trucking along, writing some other functionality and I finally compiled the code…  I fixed the compilation errors (usually missing semi-colons or curly brackets) and I went to test.  I had a test directory C:\testdir\testdata where the tool was to be run in testdir and the data to be put in the cab file was in testdata. 


Of course at 2:30am I am not thinking about the code I wrote an hour or two before, nor do I think about running this under the debugger.  No I dragged the tool from the debug directory straight into a default command prompt.  I was puzzled as the code did not return.  So I went and looked at the code, thinking I might have done something wrong.  I spent about 10 minutes looking.  I figured it was hung somewhere so I looked for any potential hanging points – maybe a for loop where I put a greater than sign where I needed a less than sign or something like that.  I went to control + C the running code and I caught a glimpse of my desktop…


Zero icons.  Of course I had no browsing history anymore either.  No PST’s.  No documents in the My Documents folder. 


My default command prompt centers at %userprofile%…  the “true” in the Directory.Delete means “go into all of the sub directories and torch everything.”


Luckily I had a fairly recent backup.  For the rest I used a third party file recovery tool. 


 


 


 


This posting is provided “AS IS” with no warranties, and confers no rights.

Comments (0)