Directory.Move not working over volumes with CopyAllowed
See original GitHub issueUsing .NET 3.5 and the 3.5 lib from AlphaFS.2.0.1.zip DIrectory.Move across volumes is not working even with the CopyAllowed option set.
eg.
Dim l_SourceFolderPath As String = "C:\Temp\Test1"
Dim l_TargetFolderPath As String = "E:\Temp\Test2"
Alphaleonis.Win32.Filesystem.Directory.Move( _
l_SourceFolderPath, _
l_TargetFolderPath, _
Alphaleonis.Win32.Filesystem.MoveOptions.CopyAllowed)
This fails with the following exception:
System.UnauthorizedAccessException occurred Message=(5) Access is denied: [?\E:\Temp\Test2] Source=AlphaFS StackTrace: at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath) in d:\Coding\Projects\GitHub\AlphaFS\AlphaFS\NativeError.cs:line 102 InnerException:
Directory Copy and Delete works fine, so it is not a permission issue with either of the folders.
Alphaleonis.Win32.Filesystem.Directory.Copy( _
l_SourceFolderPath, _
l_TargetFolderPath)
Alphaleonis.Win32.Filesystem.Directory.Delete( _
l_SourceFolderPath, _
True)
I assumed this is what the MoveOptions.CopyAllowed option was supposed to do?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11
Top Results From Across the Web
"Move will not work across volumes" - Why? And how to ...
Move has a condition that states that : IO Exception will be thrown if an attempt was made to move a directory to...
Read more >Moving Files on the Same NTFS Volume does NOT Inherit ...
I had a client complain that suddenly when using my app to move a file, the target folder permissions were not being inherited...
Read more >Directory.Move Method (String, String, MoveOptions ... - AlphaFS
This method does not work across disk volumes unless moveOptions contains CopyAllowed. Whenever possible, avoid using short file names (such as XXXXXX~1.
Read more >System.IO.Directory.Move fails between two mounts on Linux
Move will not work across volumes." [C:\Users\Robert Holt\Documents\Dev\Microsoft\PSScriptAnalyzer]> get-error Exception : Type : System.
Read more >Directory.Move via Invoke Method - Studio
To resolve the issue, you can copy the directory from the source to the destination and then delete the original directory from the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, I just tested with the .NET 3.5 version and get the same error. I’ll test with the .NET 4 version tomorrow and let you know if any difference.
For referece I used: https://github.com/alphaleonis/AlphaFS/blob/develop/AlphaFS-NET35.zip
Hm… seems I did something wrong with the .NET 3.5 dll. Since the code is the same for .NET 3.5 and .NET 4.0 we can regard it as resolved.