Open File

Parent Previous Next

Open File

Function to open a text file.


Syntax:

Boolean open(String pathName, Boolean overwrite);
Try to open a text file passed in the parameter setting if it will overwrite the content in it or not.


Params:

String pathName: A String parameter containing the full path of the file including the filename and the extension.

Boolean overwrite: A Boolean parameter setting if the file will be overwrite or if it will be open in append mode, that is, if the user execute some Write event the text will be written in the end of the file.


Return:

True: The file was opened successfully.

False: The file was not opened successfully.


Example:

In this example, we are trying to open the file "OpenFunction.txt" located in the path "C:\" and overwriting the existing content of the file. If the file is opened successfully the user will write a line in it and if it fail the user will write a message in the Engineering Log.

  


@OpenFileSuccessfully = SVFile.Open("C:\OpenFunction.txt", true);

if(@OpenFileSuccessfully == true )

SVFile.WriteLine("File Open Successfully");

else

SVApplications.Output("File could not be opened");