question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directory.Move not working over volumes with CopyAllowed

See original GitHub issue

Using .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:closed
  • Created 7 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
frontier777commented, Sep 21, 2016

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

0reactions
Yomodocommented, Sep 28, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found