about_IOInfoExtensions.PowerShell_MoveFrom.help.txt
TOPIC
about_IOInfoExtensions.PowerShell_MoveFrom SHORT DESCRIPTION Moves the source file to the destination file. If the destination file exists and overwrite is false, an exception will be thrown. System.IO.FileInfo has a MoveTo method, but it changes the Source object information to match the destination properties.This method will allow you to call the move from the destination, leaving the source unchanged. SYNTAX MoveFrom(System.IO.FileInfo source, [bool overwrite = False]) PARAMETERS source <System.IO.FileInfo> The source FileInfo object to be moved. Required: True Default Value: Accepts Wildcard Characters: False overwrite <System.Boolean> Indicates if the destination file should be overwritten if it exists. Required: False Default Value: False Accepts Wildcard Characters: False EXCEPTIONS System.IO.FileNotFoundException If the source file does not exist. System.IO.IOException If the destination file exists but overwrite is not set to true. EXAMPLES --------------------- Example 1 --------------------- PS> $sourceFile = New-Object System.IO.FileInfo 'C:\Demo\ChildFile1.txt' PS> $newFile = New-Object System.IO.FileInfo 'C:\Demo\ChildDir3\ChildFile3.txt' $sourceFile, $newFile | Select-Object Directory, Name, @{n='DirectoryExists';e={$_.Directory.Exists}}, Exists Directory Name DirectoryExists Exists --------- ---- --------------- ------ C:\Demo ChildFile1.txt True True C:\Demo\ChildDir3 ChildFile3.txt False False $newFile.MoveFrom($sourceFile) $sourceFile, $newFile | Select-Object Directory, Name, @{n='DirectoryExists';e={$_.Directory.Exists}}, Exists Directory Name DirectoryExists Exists --------- ---- --------------- ------ C:\Demo ChildFile1.txt True False C:\Demo\ChildDir3 ChildFile3.txt True True KEYWORDS IOInfoExtensions, IOInfoExtensions.PowerShell, System.IO.FileInfo, FileInfo, MoveFrom SEE ALSO about_IOInfoExtensions.PowerShell about_IOInfoExtensions.PowerShell_GetDirectory about_IOInfoExtensions.PowerShell_GetFile about_IOInfoExtensions.PowerShell_DeleteContent about_IOInfoExtensions.PowerShell_CopyContentTo about_IOInfoExtensions.PowerShell_MoveFrom about_IOInfoExtensions.PowerShell_CopyFrom about_IOInfoExtensions.PowerShell_TryDelete |