System.IO.FileSystem.MoveFile C# (CSharp) Méthode

MoveFile() public abstract méthode

public abstract MoveFile ( string sourceFullPath, string destFullPath ) : void
sourceFullPath string
destFullPath string
Résultat void
        public abstract void MoveFile(string sourceFullPath, string destFullPath);

Usage Example

Exemple #1
0
        // Moves a given file to a new location and potentially a new file name.
        // This method does work across volumes.
        public void MoveTo(string destFileName)
        {
            if (destFileName == null)
            {
                throw new ArgumentNullException(nameof(destFileName));
            }
            if (destFileName.Length == 0)
            {
                throw new ArgumentException(SR.Argument_EmptyFileName, nameof(destFileName));
            }

            string fullDestFileName = Path.GetFullPath(destFileName);

            // These checks are in place to ensure Unix error throwing happens the same way
            // as it does on Windows.These checks can be removed if a solution to #2460 is
            // found that doesn't require validity checks before making an API call.
            if (!new DirectoryInfo(Path.GetDirectoryName(FullName)).Exists)
            {
                throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, FullName));
            }

            if (!Exists)
            {
                throw new FileNotFoundException(SR.Format(SR.IO_FileNotFound_FileName, FullName), FullName);
            }

            FileSystem.MoveFile(FullPath, fullDestFileName);

            FullPath     = fullDestFileName;
            OriginalPath = destFileName;
            _name        = Path.GetFileName(fullDestFileName);

            // Flush any cached information about the file.
            Invalidate();
        }
All Usage Examples Of System.IO.FileSystem::MoveFile