Difference between revisions of "FileNamespace class"

From Catglobe Wiki
Jump to: navigation, search
m (moved File Class to File class)
(No difference)

Revision as of 12:20, 8 March 2013

File API



Class of Write and Read File


Methods

  • DateTime GetCreationTime(string filename "Name of the file on server", bool isTemp "Is the file temporary") - Returns the creation date and time of the specified file on server.
  • string GetDownloadPath(string filename "Name of the file on server ", bool isTemp "Is the file temporary") - Generates URL to download the file from site_address/Public/CgsFile.aspx?tempfile=filename&saveas=filename.
  • DateTime GetLastWriteTime(string filename "Name of the file on server.", bool isTemp "Is the file temporary") - Returns the date and time the specified file on server was last written to.
  • array ReadAllLines(string filename "Name of the file on server", bool isTemp "Is the file temporary") - Opens a text file, reads all lines of the file, and then closes the file.
  • string ReadAllText(string filename "Name of the file on server", bool isTemp "Is the file temporary") - Opens a text file, reads all lines of the file (on server), and then closes the file.
  • string ToString() - The string representation of the object.
  • Empty WriteAllLines(string filename "Name of the file on server", bool isTemp "Is the file temporary", array content "The content of the file") - Opens a text file, Writes all lines of the file, Saves, and then closes the file on server. If there is duplicated file name on server, it will be written on. (Content of last file loses)
  • Empty WriteAllText(string filename "Name of the file on server.", bool isTemp "Is the file temporary", string content "The content of the file") - Opens a text file, Writes all lines of the file, Saves, and then closes the file on server. If there is duplicated file name on server, it will be written on. (Content of last file loses).

Properties

  • string ObjectTypeName { get; } - The name of the type of object.
  • TypeInformation TypeInformation { get; } - Get information about this class.

 
 

Examples
 

array a= {"Hello", "World"}; // array to write file
string b = "Hello World";    // string to write file
bool isTemp = false;         // false is temporary file

Catglobe.File.WriteAllLines("helloworld.txt", isTemp, a);         // write array a to file
print(Catglobe.File.ReadAllLines("helloworld.txt", isTemp));      // result : {Hello,World}
print(Catglobe.File.GetDownloadPath("helloworld.txt", isTemp));   // get download path
print(Catglobe.File.GetCreationTime("helloworld.txt", isTemp));   // get creation time
print(Catglobe.File.GetLastWriteTime("helloworld.txt", isTemp));  // get last write time
Catglobe.File.WriteAllText("helloworld.txt", isTemp, b);          // string b to file
Catglobe.File.ReadAllText("helloworld.txt", isTemp);              // result : Hello World