Toggle menu
876
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

FileNamespace class: Difference between revisions

From Catglobe Wiki
Created page with "Category:Classes"
 
No edit summary
Line 1: Line 1:
{{CGscriptClass_Template |Name=<nowiki>File API</nowiki> |Description=<nowiki>Class of Write and Read File</nowiki> |Methods= {{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>GetCreationTime</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>}}
|Description=<nowiki>Returns the creation date and time of the specified file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>GetDownloadPath</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>}}
|Description=<nowiki>Generates URL to download the file from.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>GetLastWriteTime</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>}}
|Description=<nowiki>Returns the date and time the specified file was last written to.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>ReadAllLines</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>}}
|Description=<nowiki>Opens a text file, reads all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ReadAllText</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>}}
|Description=<nowiki>Opens a text file, reads all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>Opens a text file, reads all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>WriteAllLines</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>content</nowiki>|Description=<nowiki>The content of the file</nowiki>}}|Description=<nowiki>Opens a text file, Writes all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>WriteAllText</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>filename</nowiki>|Description=<nowiki>Name of the file</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=<nowiki>isTemp</nowiki>|Description=<nowiki>Is the file temporary</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>content</nowiki>|Description=<nowiki>The content of the file</nowiki>}}|Description=<nowiki>Opens a text file, Writes all lines of the file, and then closes the file.</nowiki>}}
|Properties= {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
}} <br> <br>
==== <span style="color: rgb(165, 42, 42);">'''Examples'''</span><br>&nbsp;  ====
<source lang="javascript">
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
</source> <br>
[[Category:Classes]]
[[Category:Classes]]

Revision as of 08:36, 8 March 2013

File API



Class of Write and Read File


Methods

  • DateTime GetCreationTime(string filename "Name of the file", bool isTemp "Is the file temporary") - Returns the creation date and time of the specified file.
  • string GetDownloadPath(string filename "Name of the file", bool isTemp "Is the file temporary") - Generates URL to download the file from.
  • DateTime GetLastWriteTime(string filename "Name of the file", bool isTemp "Is the file temporary") - Returns the date and time the specified file was last written to.
  • array ReadAllLines(string filename "Name of the file", 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", bool isTemp "Is the file temporary") - Opens a text file, reads all lines of the file, and then closes the file.
  • string ToString() - Opens a text file, reads all lines of the file, and then closes the file.
  • Empty WriteAllLines(string filename "Name of the file", bool isTemp "Is the file temporary", array content "The content of the file") - Opens a text file, Writes all lines of the file, and then closes the file.
  • Empty WriteAllText(string filename "Name of the file", bool isTemp "Is the file temporary", string content "The content of the file") - Opens a text file, Writes all lines of the file, and then closes the file.

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