Opens the file for which a path has already been specified.

syntaxSyntax:
DlxFile.Open(mode, itemIndex=-1)

Parameters

Parameter Description
openMode File access options for the specified file. Must be one of the following values:
DlxApp.FILEOPEN_READTEXT Opens the file for reading as a text file.
Ex: file.Open(DlxApp.FILEOPEN_READTEXT);
DlxApp.FILEOPEN_WRITETEXT Opens the file in writing as a text file.
Ex: file.Open(DlxApp.FILEOPEN_WRITETEXT);
DlxApp.FILEOPEN_READBINARY Opens the file for reading as a binary data file.
Ex: file.Open(DlxApp.FILEOPEN_READBINARY);
DlxApp.FILEOPEN_WRITEBINARY Opens the file in writing as a binary data file.
Ex: file.Open(DlxApp.FILEOPEN_WRITEBINARY);
DlxApp.FILEOPEN_ZIP Opens the file for writing as a zip-type compressed file. After creating the file you can add the files with the AddFile function.
Ex: file.Open(DlxApp.FILEOPEN_ZIP);
DlxApp.FILEOPEN_UNZIP Opens the file for reading as a compressed zip-type file. After opening the file, you can unzip the files with the UnzipFile function.
Ex: file.Open(DlxApp.FILEOPEN_UNZIP);
DlxApp.FILEOPEN_UNZIPTEXT Opens the file indicated by itemIndex for reading as a text file. The file is extracted from a compressed zip-type archive.
Ex: file.Open(DlxApp.FILEOPEN_UNZIPTEXT, 1);
DlxApp.FILEOPEN_UNZIPBINARY Opens the file indicated by itemIndex for reading as a binary data file. The file is extracted from a compressed zip-type archive.
Ex: file.Open(DlxApp.FILEOPEN_UNZIPBINARY, 1);
itemIndex Used in conjunction with the DlxApp.FILEOPEN_UNZIPTEXT and DlxApp.FILEOPEN_UNZIPBINARY modes. Specifies the index of the file contained in the compressed archive. The index must be between 0 and GetItemsCount-1.

Return Value

If the operation ends correctly it returns true otherwise it returns false.

Example

  Copy codeCopy code
// Acquire the file to import
var file = new DlxFile("", DlxApp.FILEOPEN_OPENDIALOG|DlxApp.FILEOPEN_ALLFILES, -1, "Component Interchange Format|*.cxf|Compressed archive|*.zip");
if (file.IsValid())
{
  if (file.GetFileExt() == ".zip")
  {
    // If it is a compressed archive, look for the .cxf file
    if (file.Open(DlxApp.FILEOPEN_UNZIP))
      file.Open(DlxApp.FILEOPEN_UNZIPTEXT, file.FindItemByExt(".cxf"));
  }
  else
  {
    // If it is a .cxf file simply open it
    file.Open(DlxApp.FILEOPEN_READTEXT);
  }
  // Reading .CXF file
  while (!file.IsEOF())
    DlxApp.Printf(file.ReadLine());
}

See also