You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
A small snippet being better than a long description:
var dir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(dir);
// works
using (var x = File.Open(Path.Combine(dir, "sysio.txt"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete))
System.IO.File.Move(Path.Combine(dir, "sysio.txt"), Path.Combine(dir, "sysio-moved.txt"));
// throws, but the move is successfuly performed (The process cannot access the file because it is being used by another process)
using (var x = File.Open(Path.Combine(dir, "alphafs.txt"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete))
Alphaleonis.Win32.Filesystem.File.Move(Path.Combine(dir, "alphafs.txt"),Path.Combine(dir, "alphafs-moved.txt"));
File.Move is supposed to be successful when the file has been open with FileShare.Delete flag.
In this case, File.Move sucessfully moves the file, but throws an exception (wtf ?).
NB: This issue is specific to File.Move, FileShare.Delete works perfectly fine with File.Delete()
The text was updated successfully, but these errors were encountered:
Yomodo
changed the title
[bug] File.Move on a file opened with FileShare.Delete : succeeds, but throws IOException
File.Move on a file opened with FileShare.Delete succeeds but throws IOException.
Jul 13, 2018
A small snippet being better than a long description:
File.Move is supposed to be successful when the file has been open with FileShare.Delete flag.
In this case, File.Move sucessfully moves the file, but throws an exception (wtf ?).
NB: This issue is specific to File.Move, FileShare.Delete works perfectly fine with File.Delete()
The text was updated successfully, but these errors were encountered: