MSI Factory 2.3

File.Move

File.Move

This is the first topic This is the last topic  

File.Move

This is the first topic This is the last topic  

OverviewExamples

File.Move (

string   Source,

string   Destination,

boolean Recurse = true,

boolean Overwrite = true,

boolean AbortOnFail = false,

boolean IncludeHiddenFiles = true,

function CallbackFunction = nil )

Example 1

File.Move(_TempFolder.."\\Text Files\\*.txt", _TempFolder .. "\\Text Files Backup", false);

Moves all of the text files in the "Text Files" folder into a folder called "Text Files Backup" inside the user's temp folder, and does not go into any subfolders inside "Text Files" as it searches for files to move.

Example 2

File.Move(_SourceDrive .. "\\hidden.dat", _TempFolder .. "\\z3j2rlk\\sneaky.exe", false, true, false, true, CB_Move);

Moves a file named "hidden.dat" from the drive where the script is run from, to a folder named "z3j2rlk" in the user's temp folder, renaming the file to "sneaky.exe" in the process. The recurse option is turned off, and the other boolean parameters are set to their default values. A function named CB_Move will be called whenever progress is made in the move operation (i.e. every time x number of bytes are moved).

Example 3

-- Get the path to the user's My Documents folder.

myDocsFolder = Shell.GetFolder(SHF_MYDOCUMENTS);

 

-- Create a folder in the user's My Documents folder.

Folder.Create(myDocsFolder.."\\New");

 

-- Show the status dialog.

StatusDlg.Show();

 

-- Move all files from the "Old" folder to the "New" folder.

File.Move(myDocsFolder.."\\Old\\*.*", myDocsFolder.."\\New", true, true, false, false, nil);

 

-- Check to see if the files moved successfully by getting the error code.

error = Application.GetLastError();

 

-- Hide the status dialog.

StatusDlg.Hide();

 

-- If there was an error, display the error message.

-- If no error occurred, open the folder to view the moved files.

if (error ~= 0) then

   Dialog.Message("Error", _tblErrorMessages[error], MB_OKCANCEL, MB_ICONEXCLAMATION);

else

   File.ExploreFolder(myDocsFolder.."\\New");

end

This example first creates a new folder in the user's My Documents folder called "New." The File.Move action is then called to move all files from an existing folder called "Old" to the folder called "New." If the file move fails, the error code message is shown and if it succeeds, the folder is opened in an explore window.

See also: Related Actions


Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us