alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
563 stars 99 forks source link

Directory.Move operation worked in v2.0.1, but now fails in v.2.2.1 #434

Closed warrenlbrown closed 6 years ago

warrenlbrown commented 6 years ago

`This worked in v2.0.1, but fails in latest release v2.2.1

string srcFile = @"C:\$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log"; string dstFile = @"T:\$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log";

MoveOptions options = MoveOptions.CopyAllowed | MoveOptions.WriteThrough; options |= MoveOptions.ReplaceExisting; Directory.Move(source, destination, options);

Error moving C:\$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log to T:\$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log: System.IO.IOException: (267) The directory name is invalid: [C:\$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log] at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\NativeError.cs:line 87 at Alphaleonis.Win32.Filesystem.FindFileSystemEntryInfo.ThrowPossibleException(UInt32 lastError, String pathLp) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\FindFileSystemEntryInfo.cs:line 404 at Alphaleonis.Win32.Filesystem.FindFileSystemEntryInfo.FindFirstFile(String pathLp, WIN32_FIND_DATA& win32FindData, Boolean suppressException) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\FindFileSystemEntryInfo.cs:line 297 at Alphaleonis.Win32.Filesystem.FindFileSystemEntryInfo.d__841.MoveNext() in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\FindFileSystemEntryInfo.cs:line 459 at Alphaleonis.Win32.Filesystem.Directory.CopyDeleteCore(KernelTransaction transaction, String sourcePathLp, String destinationPathLp, Boolean preserveDates, Boolean emulateMove, Nullable1 copyOptions, CopyMoveProgressRoutine progressHandler, Object userProgressData, CopyMoveResult copyMoveResult) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\Directory Class\Directory.Copy.cs:line 803 at Alphaleonis.Win32.Filesystem.Directory.CopyMoveCore(KernelTransaction transaction, String sourcePath, String destinationPath, Boolean preserveDates, Nullable1 copyOptions, Nullable1 moveOptions, CopyMoveProgressRoutine progressHandler, Object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\Directory Class\Directory.Copy.cs:line 748 at Alphaleonis.Win32.Filesystem.Directory.Move(String sourcePath, String destinationPath, MoveOptions moveOptions) in C:\Users\brown.SHERPA\Downloads\AlphaFS-2.2.1\AlphaFS-2.2.1\AlphaFS\Filesystem\Directory Class\Directory.Move.cs:line 151 at SherpaSoftware.IO.LongPathTools.MoveFile(String source, String destination, Boolean overWrite) in T:\SVN WORK\Utils\DebugHound\Externals\SharedLibs\sherpaSoftware.Common\sherpaSoftware.Common\IO\LongPathTools.cs:line 2949 at SherpaSoftware.IO.Files.Move(String source, String destination, Boolean overWrite) in T:\SVN WORK\Utils\DebugHound\Externals\SharedLibs\sherpaSoftware.Common\sherpaSoftware.Common\IO\Main.cs:line 528 at sherpaSoftware.DebugHound.dlgMainForm.mnuMoveFile_Click(Object sender, EventArgs e) in T:\SVN WORK\Utils\DebugHound\DebugHound\dlgMainForm.cs:line 8490 `

Yomodo commented 6 years ago

I'm a bit confused, are you performing a Directory.Move on the log file?

string srcFile = @"C:$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log";

System.IO.IOException: (267) The directory name is invalid: [C:$Sherpa Software\Altitude\Agents\SP\Logs\2018_04_06.log
Yomodo commented 6 years ago

@warrenlbrown: I guess the error is: (267) The directory name is invalid, and not a Directory.Move error. Could you confirm/clarify or close this issue.

warrenlbrown commented 6 years ago

This is a bug/regression. Note MS docs https://msdn.microsoft.com/en-us/library/system.io.directory.move(v=vs.110).aspx. src and dest can both be files

Thank you.

Yomodo commented 6 years ago

Ok, it's clear now what you want to do.