IFileOperations

IFileOperations

This interface allows you to access all the operations.

Declaration

IFileOperations : IDispatch

Properties

IFiles(string aType)
- Gets the collection of files of the specified type. Returns an array of file objects.

SupportedOperations()
- Gets the list of supported file operations for the current project.

Methods

NewCopyMoveFile(IFolder aSourceFolder, String aSourceFileName, IFolder aDestinationFolder, String aDestinationFileName, String aOperation) returns IMoveFile
- Creates a new operation that copies or moves a file from the source folder to the destination folder, where aOperation will receive “Copy” or “Move” arg..

NewDownloadFile(IFolder aFolder, String aFileName, String aUrl) returns IDownloadFile
- Creates a new download operation that retrieves a file from the specified URL and saves it in the given folder.

NewDuplicateFile(IFile aFile) returns IDuplicateFile
- Creates a new operation that duplicates the specified file..

NewRemoveFile(IFolder aFolder, String aFileName) returns IRemoveFile
- Creates a new operation that removes the specified file from the folder..

RemoveFile(IFolder aFolder, String aType, String aFile) returns void
- Removes a file of the specified type from the given folder.

IExtractArchive NewExtractArchive (IFolder aFolder, string aSourcePath) Create extract archive operation

Examples

D:\JobAI\advinst\win\Debug\bin\x86\advinst.exe /REGSERVER
$projPath = "C:\Users\Marina\Downloads\projtest.aip"
$advinst = new-object -comObject "AdvancedInstaller"
$proj = $advinst.CreateProject($advinst.ProjectTypes.Architect)
$file = $proj.FilesComponent.AddFile($proj.PredefinedFolders.ApplicationFolder,"C:\Users\Marina\Downloads\code_g1 (7).jpeg")

$proj.FilesComponent.FileOperation.NewRemoveFile($proj.PredefinedFolders.ApplicationFolder, "code_g1 (7).jpeg")
$copyFile = $proj.FilesComponent.FileOperation.NewCopyMoveFile($proj.PredefinedFolders.ApplicationFolder, "tesst.txt", $proj.PredefinedFolders.ApplicationFolder ,"code_g1 (7).jpeg", "Copy")
$copyFile.ExecuteOn = "InstallAndUninstall"
$proj.FilesComponent.FileOperation.NewRemoveFile($proj.PredefinedFolders.ApplicationFolder, "code_g1 (7).jpeg")
$proj.FilesComponent.FileOperation.NewDuplicateFile($proj.PredefinedFolders.applicationFolder.Files[0])
$proj.FilesComponent.fileoperation.NewDownloadFile($proj.PredefinedFolders.ApplicationFolder, "gaga.txt", "testurl.com")

$proj.FilesComponent.fileoperation.Files("FileDownload")
$proj.FilesComponent.fileoperation.Files("DuplicateFile")
$proj.FilesComponent.fileoperation.Files("RemoveFile")
$proj.FilesComponent.fileoperation.Files("MoveFile")


$proj.FilesComponent.fileoperation.RemoveFile($proj.PredefinedFolders.ApplicationFolder,"RemoveFile", "code_g1 (7).jpeg")
$proj.FilesComponent.fileoperation.RemoveFile($proj.PredefinedFolders.ApplicationFolder,"DuplicateFile", "code_g1 (7).jpeg")
$proj.FilesComponent.fileoperation.RemoveFile($proj.PredefinedFolders.ApplicationFolder,"FileDownload", "gaga.txt")
$proj.PredefinedFolders.ApplicationFolder.Folders[0].Operations
$proj.saveAs($projPath)

$proj.FilesComponent.fileoperation.Files("FileDownload")[0]  | gm
$proj.FilesComponent.fileoperation.Files("MoveFile")[0] | gm
$proj.FilesComponent.fileoperation.Files("DuplicateFile")[0] | gm
$proj.FilesComponent.fileoperation.Files("RemoveFile")[0] | gm
    

Topics