System::CreateFile

System::CreateFile create or opens a file resource for reading or writing. This static method will check to see is the currently executing script has the appropriate permissions to the desired file before allowing the underline function to be called. This will block access to files even if the current process is executing as a user who has permissions under Windows native security protocols.

public System::CreateFile(
   WString FileName,
   Integer Flags = System::READ_ONLY | System::OPEN_EXISTING
:  OSHandle FileHandle
);

Parameters

FileNamethe name of the file to be opened or created.
Flagsthe Flags can be one of the following:- System::CREATE_ALWAYS, System::CREATE_NEW, System::OPEN_ALWAYS, System::OPEN_EXISTING, System::TRUNCATE_EXISTING and or'ed with System::READ_ONLY if no write access is required.
FileHandlethe returned file handle if the static method does not return an error.

Return Values

The error.errorCode value will be set to the underlining windows error message code and the error.errorString will have a detailed description of the error.

Remarks

Example Use
  • TScript
main(){
   variable fileHandle, fileBuffer;
   System::CreateFile(u"MyFile.txt",
      System::OPEN_EXISTING|System::READ_ONLY:fileHandle);
   System::ReadFile(fileHandle:fileBuffer);
   System::MessageBox(fileBuffer.ToString(),
      u"File Contents of MyFile.txt");
}

Since

TScript Version 1.0

Also See

System::ReadFile, System::SetFilePointer, System::WriteFile
Listen All
Comments (0)
Characters left: 2500
 
Ekky Software Homepage T-Accounts Online ObjectDatabase++ TScript Ekky Software Homepage T-Accounts Onlinee ObjectDatabase++ TScript