Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Move()

static void System.IO.Directory.Move ( string sourceDirName,
string destDirName )
inlinestatic

Definition at line 304 of file Directory.cs.

305 {
306 if (sourceDirName == null)
307 {
308 throw new ArgumentNullException("sourceDirName");
309 }
310 if (sourceDirName.Length == 0)
311 {
312 throw new ArgumentException(SR.Argument_EmptyFileName, "sourceDirName");
313 }
314 if (destDirName == null)
315 {
316 throw new ArgumentNullException("destDirName");
317 }
318 if (destDirName.Length == 0)
319 {
320 throw new ArgumentException(SR.Argument_EmptyFileName, "destDirName");
321 }
322 string fullPath = Path.GetFullPath(sourceDirName);
323 string text = PathInternal.EnsureTrailingSeparator(fullPath);
324 string fullPath2 = Path.GetFullPath(destDirName);
325 string text2 = PathInternal.EnsureTrailingSeparator(fullPath2);
326 ReadOnlySpan<char> fileName = Path.GetFileName(fullPath.AsSpan());
327 ReadOnlySpan<char> fileName2 = Path.GetFileName(fullPath2.AsSpan());
328 StringComparison stringComparison = PathInternal.StringComparison;
329 bool flag = !fileName.SequenceEqual(fileName2) && MemoryExtensions.Equals(fileName, fileName2, StringComparison.OrdinalIgnoreCase) && MemoryExtensions.Equals(fileName2, fileName, stringComparison);
330 if (!flag && string.Equals(text, text2, stringComparison))
331 {
332 throw new IOException(SR.IO_SourceDestMustBeDifferent);
333 }
334 ReadOnlySpan<char> pathRoot = Path.GetPathRoot(text.AsSpan());
335 ReadOnlySpan<char> pathRoot2 = Path.GetPathRoot(text2.AsSpan());
336 if (!MemoryExtensions.Equals(pathRoot, pathRoot2, StringComparison.OrdinalIgnoreCase))
337 {
338 throw new IOException(SR.IO_SourceDestMustHaveSameRoot);
339 }
340 if (!FileSystem.DirectoryExists(fullPath) && !FileSystem.FileExists(fullPath))
341 {
342 throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, fullPath));
343 }
344 if (!flag && FileSystem.DirectoryExists(fullPath2))
345 {
346 throw new IOException(SR.Format(SR.IO_AlreadyExists_Name, fullPath2));
347 }
348 if (!flag && Exists(fullPath2))
349 {
350 throw new IOException(SR.Format(SR.IO_AlreadyExists_Name, fullPath2));
351 }
352 FileSystem.MoveDirectory(fullPath, fullPath2);
353 }
static bool Exists([NotNullWhen(true)] string? path)
Definition Directory.cs:43

References System.SR.Argument_EmptyFileName, System.IO.FileSystem.DirectoryExists(), System.IO.PathInternal.EnsureTrailingSeparator(), System.MemoryExtensions.Equals(), System.IO.Directory.Exists(), System.IO.FileSystem.FileExists(), System.SR.Format(), System.IO.Path.GetFileName(), System.IO.Path.GetFullPath(), System.IO.Path.GetPathRoot(), System.SR.IO_AlreadyExists_Name, System.SR.IO_PathNotFound_Path, System.SR.IO_SourceDestMustBeDifferent, System.SR.IO_SourceDestMustHaveSameRoot, System.IO.FileSystem.MoveDirectory(), System.IO.PathInternal.StringComparison, and System.text.

Referenced by System.IO.IsolatedStorage.IsolatedStorageFile.MoveDirectory().