Difference between revisions of "FileNamespace class"

From Catglobe Wiki
Jump to: navigation, search
 
Line 1: Line 1:
 
{{CGscriptClass_Template
 
{{CGscriptClass_Template
|Name=FileNamespace
+
|Name=<nowiki>FileNamespace</nowiki>
|Description=The file namespace
+
|Description=<nowiki>The file namespace</nowiki>
|Methods=
+
|InheritsFrom=object|Methods=
{{CGscriptMethods_Template|ReturnType=Empty|Name=AppendAllLines|Parameters=
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AppendAllLines</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|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}}
+
{{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=Opens a text file, Append all lines of the file, and then closes the file.}}
+
|Description=<nowiki>Opens a text file, Append all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=AppendAllText|Parameters=
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AppendAllText</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|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}}
+
{{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=Opens a text file, Append all lines of the file, and then closes the file.}}
+
|Description=<nowiki>Opens a text file, Append all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=Delete|Parameters=
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>AsHtmlBase64</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
{{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=Deletes a file.}}
+
|Description=<nowiki>Generates html base64 url.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=GenerateRandomFilename|Description=Provides a new random filename.}}
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Delete</nowiki>|Parameters=
{{CGscriptMethods_Template|ReturnType=DateTime|Name=GetCreationTime|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>}}
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
|Description=<nowiki>Deletes a file.</nowiki>}}
|Description=Returns the creation date and time of the specified file.}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>GenerateRandomFilename</nowiki>|Description=<nowiki>Provides a new random filename.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=GetDownloadPath|Parameters=
+
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>GetCreationTime</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
{{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=Generates URL to download the file from.}}
+
|Description=<nowiki>Returns the creation date and time of the specified file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=GetDownloadPath|Parameters=
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>GetDownloadPath</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=downloadas|Description=Name of the file as presented to the user to save}}
+
{{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=Generates URL to download the file from.}}
+
|Description=<nowiki>Generates URL to download the file from.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=DateTime|Name=GetLastWriteTime|Parameters=
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>GetDownloadPath</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
{{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>downloadas</nowiki>|Description=<nowiki>Name of the file as presented to the user to save</nowiki>}}
|Description=Returns the date and time the specified file was last written to.}}
+
|Description=<nowiki>Generates URL to download the file from.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=array|Name=ReadAllLines|Parameters=
+
{{CGscriptMethods_Template|ReturnType=DateTime|Name=<nowiki>GetLastWriteTime</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
{{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=Opens a text file, reads all lines of the file, and then closes the file.}}
+
|Description=<nowiki>Returns the date and time the specified file was last written to.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=ReadAllText|Parameters=
+
{{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>ReadAllLines</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|Comma=,}}{{CGscriptParameters_Template|Type=bool|Name=isTemp|Description=Is the file temporary}}
+
{{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=Opens a text file, reads all lines of the file, and then closes the file.}}
+
|Description=<nowiki>Opens a text file, reads all lines of the file, and then closes the file.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ReadAllText</nowiki>|Parameters=
{{CGscriptMethods_Template|ReturnType=Empty|Name=WriteAllLines|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>}}
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|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=<nowiki>Opens a text file, reads all lines of the file, and then closes the file.</nowiki>}}
|Description=Opens a text file, Writes all lines of the file, and then closes the file.}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
{{CGscriptMethods_Template|ReturnType=Empty|Name=WriteAllText|Parameters=
+
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>WriteAllLines</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=string|Name=filename|Description=Name of the file|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}}
+
{{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=Opens a text file, Writes all lines of the file, and then closes the file.}}
+
|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=
 
|Properties=
{{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}}
+
{{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=TypeInformation|HasGetter=1|Description=Get information about this class.}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
}}&nbsp;<br/>&nbsp;
+
}}
  
 
==== <span style="color: rgb(165, 42, 42)">'''Examples'''</span><br/>&nbsp;<br/> ====
 
==== <span style="color: rgb(165, 42, 42)">'''Examples'''</span><br/>&nbsp;<br/> ====

Latest revision as of 07:56, 2 July 2020

FileNamespace



The file namespace

Parent class

Inherits from object

Methods

  • Empty AppendAllLines(string filename "Name of the file", bool isTemp "Is the file temporary", array content "The content of the file") - Opens a text file, Append all lines of the file, and then closes the file.
  • Empty AppendAllText(string filename "Name of the file", bool isTemp "Is the file temporary", string content "The content of the file") - Opens a text file, Append all lines of the file, and then closes the file.
  • string AsHtmlBase64(string filename "Name of the file", bool isTemp "Is the file temporary") - Generates html base64 url.
  • Empty Delete(string filename "Name of the file", bool isTemp "Is the file temporary") - Deletes a file.
  • string GenerateRandomFilename() - Provides a new random filename.
  • 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.
  • string GetDownloadPath(string filename "Name of the file", bool isTemp "Is the file temporary", string downloadas "Name of the file as presented to the user to save") - 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.
  • (From object) string ToString() - The string representation of the object.
  • 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.
  • (From 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 
fileObj.Delete("helloworld.txt", isTemp); //
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
string file_name=fileObj.GenerateRandomFilename();
fileObj.WriteAllLines(file_name, isTemp, a); // write array a to file
print(fileObj.ReadAllLines(file_name, isTemp)); // result : {Hello,World} 
print(fileObj.GetDownloadPath(file_name, isTemp)); // get download path
print(fileObj.GetCreationTime(file_name, isTemp)); // get creation time
print(fileObj.GetLastWriteTime(file_name, isTemp)); // get last write time
fileObj.WriteAllText(file_name, isTemp, b); // string b to file
fileObj.ReadAllText(file_name, isTemp); // result : Hello World 
fileObj.Delete(file_name, isTemp); //