Difference between revisions of "FileNamespace class"
Line 1: | Line 1: | ||
− | {{CGscriptClass_Template |Name= | + | {{CGscriptClass_Template |Name=FileNamespace |Description=The file namespace |Methods= {{CGscriptMethods_Template|ReturnType=DateTime|Name=GetCreationTime|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} |
− | |Description= | + | |Description=Returns the creation date and time of the specified file on server.}} |
− | {{CGscriptMethods_Template|ReturnType=string|Name= | + | {{CGscriptMethods_Template|ReturnType=string|Name=GetDownloadPath|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server |Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} |
− | |Description= | + | |Description=Generates URL to download the file from : site_address/Public/CgsFile.aspx?file=filename}} |
− | {{CGscriptMethods_Template|ReturnType= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=Delete|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} |
− | |Description= | + | |Description=Deletes a file.}} |
− | {{CGscriptMethods_Template|ReturnType= | + | {{CGscriptMethods_Template|ReturnType=DateTime|Name=GetLastWriteTime|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server.|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} |
− | |Description= | + | |Description=Returns the date and time the specified file on server was last written to.}} |
− | {{CGscriptMethods_Template|ReturnType= | + | {{CGscriptMethods_Template|ReturnType=array|Name=ReadAllLines|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} |
− | |Description= | + | |Description=Opens a text file, reads all lines of the file, and then closes the file.}} |
− | {{CGscriptMethods_Template|ReturnType=string|Name= | + | {{CGscriptMethods_Template|ReturnType=string|Name=ReadAllText|Parameters= |
+ | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}} | ||
+ | |Description=Opens a text file, reads all lines of the file (on server), and then closes the file.}} | ||
− | {{CGscriptMethods_Template|ReturnType | + | {{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}} |
− | |||
− | {{CGscriptMethods_Template|ReturnType=Empty|Name= | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=WriteAllLines|Parameters= |
− | {{CGscriptParameters_Template|Type=string|Name= | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=content|Description=The content of the file}}|Description=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)}} |
− | | | + | {{CGscriptMethods_Template|ReturnType=Empty|Name=WriteAllText|Parameters= |
− | }} | + | {{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file on server.|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=content|Description=The content of the file}}|Description=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).}} |
− | ==== <span style="color: rgb(165, 42, 42) | + | |Properties= {{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}} {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}} |
+ | }} <br/> | ||
+ | |||
+ | ==== <span style="color: rgb(165, 42, 42)">'''Examples'''</span><br/> <br/> ==== | ||
<source lang="javascript"> | <source lang="javascript"> | ||
array a= {"Hello", "World"}; // array to write file | array a= {"Hello", "World"}; // array to write file | ||
− | string b = "Hello World"; | + | string b = "Hello World"; // string to write file |
− | bool isTemp = false; | + | bool isTemp = false; // false is temporary file |
− | Catglobe.File.WriteAllLines("helloworld.txt", isTemp, a); | + | Catglobe.File.WriteAllLines("helloworld.txt", isTemp, a); // write array a to file |
− | print(Catglobe.File.ReadAllLines("helloworld.txt", isTemp)); | + | print(Catglobe.File.ReadAllLines("helloworld.txt", isTemp)); // result : {Hello,World} |
− | print(Catglobe.File.GetDownloadPath("helloworld.txt", isTemp)); | + | print(Catglobe.File.GetDownloadPath("helloworld.txt", isTemp)); // get download path |
− | print(Catglobe.File.GetCreationTime("helloworld.txt", isTemp)); | + | print(Catglobe.File.GetCreationTime("helloworld.txt", isTemp)); // get creation time |
− | print(Catglobe.File.GetLastWriteTime("helloworld.txt", isTemp)); | + | print(Catglobe.File.GetLastWriteTime("helloworld.txt", isTemp)); // get last write time |
− | Catglobe.File.WriteAllText("helloworld.txt", isTemp, b); | + | Catglobe.File.WriteAllText("helloworld.txt", isTemp, b); // string b to file |
− | Catglobe.File.ReadAllText("helloworld.txt", isTemp); | + | Catglobe.File.ReadAllText("helloworld.txt", isTemp); // result : Hello World |
− | </source | + | </source> |
<source lang="javascript"> | <source lang="javascript"> | ||
array a= {"Hello", "World"}; // array to write file | array a= {"Hello", "World"}; // array to write file | ||
− | string b = "Hello World"; | + | string b = "Hello World"; // string to write file |
− | bool isTemp = false; | + | bool isTemp = false; // false is temporary file |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | object fileObj = Catglobe.File; // declare FileNameSpaceObject | |
+ | fileObj.WriteAllLines("helloworld.txt", isTemp, a); // write array a to file | ||
+ | print(fileObj.ReadAllLines("helloworld.txt", isTemp)); // result : {Hello,World} | ||
+ | print(fileObj.GetDownloadPath("helloworld.txt", isTemp)); // get download path | ||
+ | print(fileObj.GetCreationTime("helloworld.txt", isTemp)); // get creation time | ||
+ | print(fileObj.GetLastWriteTime("helloworld.txt", isTemp)); // get last write time | ||
+ | fileObj.WriteAllText("helloworld.txt", isTemp, b); // string b to file | ||
+ | fileObj.ReadAllText("helloworld.txt", isTemp); // result : Hello World | ||
+ | </source> |
Revision as of 05:41, 2 April 2015
FileNamespace
The file namespace
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?file=filename
- Empty Delete(string filename "Name of the file", bool isTemp "Is the file temporary") - Deletes a file.
- 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
array a= {"Hello", "World"}; // array to write file
string b = "Hello World"; // string to write file
bool isTemp = false; // false is temporary file
object fileObj = Catglobe.File; // declare FileNameSpaceObject
fileObj.WriteAllLines("helloworld.txt", isTemp, a); // write array a to file
print(fileObj.ReadAllLines("helloworld.txt", isTemp)); // result : {Hello,World}
print(fileObj.GetDownloadPath("helloworld.txt", isTemp)); // get download path
print(fileObj.GetCreationTime("helloworld.txt", isTemp)); // get creation time
print(fileObj.GetLastWriteTime("helloworld.txt", isTemp)); // get last write time
fileObj.WriteAllText("helloworld.txt", isTemp, b); // string b to file
fileObj.ReadAllText("helloworld.txt", isTemp); // result : Hello World