Orphaned file issues after a delete?

We are having an issue for a year or so that we have yet to resolve. Our network admins have kind of gave up on the issue. We have a little .Net program that copies files from one network location to another. Here are some of the key parts (if you need to know) to the code:

The Rename: (File is from the System.IO namespace)

File.SetAttributes(destFileName, FileAttributes.Normal)

File.Move(destFileName, destFileName + ".bak")

So what we are essentially doing is if we have a dll called "My.dll" we will rename it to "My.dll.bak". You all know sometimes when you have a file that has a hold on a file sometimes you can do a rename to get around it. That's exactly what we are doing to try to get it to fail file locking problems. 

At the end of the process we delete all *.bak files in the destination directory:

The Delete:

File.SetAttributes(currFile, FileAttributes.Normal)

File.Delete(currFile)


The problem were occasionally run into is that although the delete looks like the file will be successful the file will still be there (at least the OS things it is) but it will have absolutely no permission. Even domain administrators can't access or take ownership of it. When they reboot the OS the file will then be gone. I have called this files 'ghost' files but i've been told i've been using the wrong terminology because a ghost file has 0 bytes.

We have recently replaced our file server were the problem exists and installed a fresh copy of server 2012 R2 yet the problem still persist. The drive on the file server is not actually a local drive but a SAN drive (don't know if that maters). I believe we are using a xiotech SAN.

This is causing major issues because we have multiple processes that will fail because they are trying to read files from that directory but getting a read permission error when they hit those orphaned files.

Again this problem doesn't happen every time. We are seeing it maybe every couple of months and when we do its only maybe 1 to 3 files the rest of the files deleted correctly. We run this copy process almost daily.

Edit: I forgot to mentioned these orphaned files disappear when we reboot the file server. Sometimes though it can be very hard to reboot a file server that is used by everything and of course this doesn't explain "why" it happens




  • Edited by Ncage2 13 hours 23 minutes ago
August 24th, 2015 12:13pm

I'd probably ask over here about the methods being used.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral%2Cvbgeneral%2Cvcgeneral&filter=alltypes&sort=lastpostdesc

 

 

 

Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 11:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics