File System Operations


Beginning from version 2.1 IXFile provides functionality for basic file system operations, performed on individual files at the operating system level. With CopyFile, MoveFile and DeleteFile developers can perform copying, moving and deleting files as expected. CheckFile is also available for checking file existence and optionally retrieving its attributes. GetFolder can be used whenever name of special system folder is required: Windows root and system folders, temporary, current or application folder. Supporting methods MakePath and SplitPath are provided to simplify path manipulations like merging, splitting and expanding paths.

Examples

C++

// error handling is omitted for clarity


  int main(int, char**)
  {
   IFile ixf;
   long attr, exists;
   char tname[_MAX_FNAME], fname[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH];

   ixf.SetLicenseKey("YOURLICENSEKEY");

// name of a test file

   strcpy(tname,"test.dat");

// build path for working copy located in system temporary directory

   ixf.GetFolder(IXF_FOLDER_TEMP,path,_MAX_PATH);
   ixf.MakePath(path,tname,filename,_MAX_PATH);

// check if temporary file already exists 
// and does not have ARCHIVE attribute

   exists = ixf.CheckFile(filename,&attr);
   if(exists == 0 || (exists > 0 && (attr & IXF_FILE_ARCHIVE) == 0))
   {

// file does not exist or is archived 

// build path for template file located in application folder

    ixf.GetFolder(IXF_FOLDER_EXEC,path,_MAX_PATH);
    ixf.MakePath(path,tname,fname,_MAX_PATH);

// and copy template file to working copy

    ixf.CopyFile(fname,filename);

   }

    .
    .
    .


// finally delete working copy

   ixf.DeleteFile(filename);

   return(0);
  }

BASIC

' error handling is omitted for clarity


  Sub Main()

   Dim ixf As IXFile
   Dim filename As String, fname As String, tname As String
   Dim attr As Long, exists As Long

   Set ixf = New IXFile
   ixf.SetLicenseKey "YOURLICENSEKEY"

' name of a test file

   tname = "test.dat"

' build path for working copy located in system temporary directory

   filename = ixf.MakePath(ixf.GetFolder(IXF_FOLDER_TEMP),tname)

' check if temporary file already exists 
' and does not have ARCHIVE attribute

   exists = ixf.CheckFile(filename,attr)
   If(exists = 0 Or (exists > 0 And (attr And IXF_FILE_ARCHIVE) = 0)) Then

' file does not exist or is archived 

' build path for template file located in application folder

    fname = ixf.MakePath(ixf.GetFolder(IXF_FOLDER_EXEC),tname)

' and copy template file to working copy

    ixf.CopyFile fname,filename

   End If

    .
    .
    .


' finally delete working copy

  ixf.DeleteFile filename

  End Sub

See Also

CheckFile, CopyFile, MoveFile, DeleteFile, GetFolder, MakePath, SplitPath