1

In a C# .NET 7 Core console application if you do File.Move(@"\\box\stuff\video.mkv", @"\\box\stuff\fun\video.mkv") it will do a copy and then delete on that file. But if you open Windows File Explorer and move (cut & paste) the same file it will get moved in an instant. The file I want to move is 20GB, so it's not feasible to the program to copy and delete. How can do move the file in C# .NET Core the same way File Explorer does?

The network share device is a samba server so my guess is that File Explorer does a remote move call. I simply want to list the files from the server and then move them to subfolders on the same network share.

EDIT: This is different then using any of the file dialogs from windows. This is strictly a batch process which does not require any user input or feedback.

iheartcsharp
  • 1,279
  • 1
  • 14
  • 22
  • Does this answer your question? [Copy many files and directories using the system file progress dialog?](https://stackoverflow.com/questions/21240197/copy-many-files-and-directories-using-the-system-file-progress-dialog) – NineBerry Dec 15 '22 at 03:56

1 Answers1

2

Instead of using File.Move, you can try using the Move method in FileInfo class.

FileInfo fileinfo = new FileInfo(filetoMovePath); 
fileinfo.MoveTo(destFileName);

This is much faster compared to static File.

Check Remarks in this MS Doc

ShubhamWagh
  • 565
  • 2
  • 9