File.move is deleting files.

fdameron

New member
Joined
Feb 6, 2023
Messages
4
Programming Experience
10+
I am working on a windows service written mostly in c# .net framework 4.5.1 running on Windows Server 2016 Standard V. 1607. It runs just fine on the dev server, but in production the file.move function deletes the files instead of renaming them. Any thoughts on this? Thanks in advance.
 
I hope that you know that 4.5.1 has been out of support for a few years now.

Anyway, does your logging show the destination name? Does the path to the destination exist? Does the account under which the service is running under have create/write permissions to the destination?
 
I hope that you know that 4.5.1 has been out of support for a few years now.

Anyway, does your logging show the destination name? Does the path to the destination exist? Does the account under which the service is running under have create/write permissions to the destination?

Out of support, yep. The version is not up to me.

Logging shows old and new names. The path exists and permissions are applied. As the service has been in use for years. Since it only happens in production, I'm fairly certain it's a server issue. Since I'm not a server admin, I wouldn't know where to look for the issue. I've even watched the files get deleted when they should be renamed.
 
Presumably, no exceptions were thrown, and the antivirus is not holding files in quarantine.

You will have to work with your OPs people to narrow down what changed recently.

As you can see from the .NET source code, File.Move() is just a very thin layer on top of the Win32 API to do file moves.
 
Presumably, no exceptions were thrown, and the antivirus is not holding files in quarantine.

You will have to work with your OPs people to narrow down what changed recently.

As you can see from the .NET source code, File.Move() is just a very thin layer on top of the Win32 API to do file moves.

Thanks for the response.
 
While working with your Ops team, see if they can run ProcMon while trying to reproduce the problem. In the past we've found it helpful when trying to help teams figure out why something is failing.

 
I too think you'll find something else is deleting the destination file. Try switching to using File.Copy and see if the destination file carries on disappearing
 
I am working on a windows service written mostly in c# .net framework 4.5.1 running on Windows Server 2016 Standard V. 1607. It runs just fine on the dev server, but in production the file.move function deletes the files instead of renaming them. Any thoughts on this? Thanks in advance.

As I expected, server updates were applied by the admin and the issue we were seeing with file.replace was resolved. This should also resolve file.move, but we won't know until we can bring the process that uses it back online.
 
Back
Top Bottom