C# Class LitDev.LDFile

Exibir arquivo Open project: litdev1/LitDev

Public Methods

Method Description
ANSItoUTF8 ( Primitive fileName, Primitive BOM ) : Primitive

Convert an ANSI encoded text file to UTF8. It should also work for any other encoding. UTF8 is the default text file encoding used by Small Basic.

AccessTime ( Primitive fileName ) : Primitive

Gets the last time a file was accessed.

CopyDirectory ( Primitive directoryFrom, Primitive directoryTo ) : Primitive

Recursively copy a directory and all contents including sub-directories.

CreationTime ( Primitive fileName ) : Primitive

Gets the creation time of a file.

Exists ( Primitive fileName ) : Primitive

Check if a file path is an existing file or directory.

GetAllDirectories ( Primitive path ) : Primitive

Recursively get all sub-directories in directory.

GetExtension ( Primitive fileName ) : Primitive

Get the file extension for a file.

GetFile ( Primitive fileName ) : Primitive

Get the file for a full file path.

GetFolder ( Primitive fileName ) : Primitive

Get the folder for a full file path.

Length ( Primitive fileName ) : Primitive

Gets the number of lines in a text file.

LoadAllVariables ( Primitive fileName ) : void

Restore the values of all variables that were previously stored using SaveAllVariables.

ModifiedTime ( Primitive fileName ) : Primitive

Gets the last time a file was modified.

PrintFile ( Primitive fileName ) : void

Print a file.

ReadANSI ( Primitive fileName ) : Primitive

Read an ANSI encoded text file. It should also work for any other encoding including UTF8. UTF8 is the default text file encoding used by Small Basic.

ReadANSIToArray ( Primitive fileName ) : Primitive

Reads a text file with ANSI encoding into an array with one element for each line in the file. It should also work for any other encoding including UTF8. Blank lines are included as an element in the array with one blank space.

ReadCSV ( Primitive fileName ) : Primitive

Read a CSV (comma separated values) file into an array. The deliminator may be changed from a comma using Utilities.CSVdeliminator

ReadCSVTransposed ( Primitive fileName ) : Primitive

Read a CSV (comma separated values) file into an array. and transpose (swap rows and columns). The deliminator may be changed from a comma using Utilities.CSVdeliminator

ReadToArray ( Primitive fileName ) : Primitive

Reads a text file into an array with one element for each line in the file. Blank lines are included as an element in the array with one blank space.

RenameDirectory ( Primitive directoryFrom, Primitive directoryTo ) : Primitive

Rename or move a directory.

RenameFile ( Primitive fileFrom, Primitive fileTo ) : Primitive

Rename or move a file.

SaveAllVariables ( Primitive fileName ) : void

Save all of the current variables to a file. This is the complete current state of your program. May be useful to store a game state, or for debugging.

Size ( Primitive fileName ) : Primitive

Get the size of a file in bytes.

WriteCSV ( Primitive fileName, Primitive array ) : void

Write a 2D array to a CSV (comma separated values) file. The deliminator may be changed from a comma using Utilities.CSVdeliminator

Private Methods

Method Description
CopyFilesRecursively ( String SourcePath, String DestinationPath ) : void
GetFileEncoding ( string fileName ) : Encoding
MusicPlayTime ( Primitive fileName ) : Primitive
ReadEncodedFile ( string fileName ) : string
getDirectories ( string dirPath, string &result, int &i ) : void

Method Details

ANSItoUTF8() public static method

Convert an ANSI encoded text file to UTF8. It should also work for any other encoding. UTF8 is the default text file encoding used by Small Basic.
public static ANSItoUTF8 ( Primitive fileName, Primitive BOM ) : Primitive
fileName Primitive The file path to convert.
BOM Primitive Include Byte Order Mark (BOM) in UTF8 file ("True" or "False", no BOM is usual).
return Primitive

AccessTime() public static method

Gets the last time a file was accessed.
public static AccessTime ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

CopyDirectory() public static method

Recursively copy a directory and all contents including sub-directories.
public static CopyDirectory ( Primitive directoryFrom, Primitive directoryTo ) : Primitive
directoryFrom Primitive The full path to the directory to copy from.
directoryTo Primitive The full path to the directory to copy to.
return Primitive

CreationTime() public static method

Gets the creation time of a file.
public static CreationTime ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

Exists() public static method

Check if a file path is an existing file or directory.
public static Exists ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file or directory. ///
return Primitive

GetAllDirectories() public static method

Recursively get all sub-directories in directory.
public static GetAllDirectories ( Primitive path ) : Primitive
path Primitive The full path to the root dircetory.
return Primitive

GetExtension() public static method

Get the file extension for a file.
public static GetExtension ( Primitive fileName ) : Primitive
fileName Primitive The file name with extension (may include folder path or not).
return Primitive

GetFile() public static method

Get the file for a full file path.
public static GetFile ( Primitive fileName ) : Primitive
fileName Primitive The full path of a file.
return Primitive

GetFolder() public static method

Get the folder for a full file path.
public static GetFolder ( Primitive fileName ) : Primitive
fileName Primitive The full path of a file.
return Primitive

Length() public static method

Gets the number of lines in a text file.
public static Length ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

LoadAllVariables() public static method

Restore the values of all variables that were previously stored using SaveAllVariables.
public static LoadAllVariables ( Primitive fileName ) : void
fileName Primitive The full path to a file with stored variable values.
return void

ModifiedTime() public static method

Gets the last time a file was modified.
public static ModifiedTime ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

PrintFile() public static method

Print a file.
public static PrintFile ( Primitive fileName ) : void
fileName Primitive The full path of the file to print.
return void

ReadANSI() public static method

Read an ANSI encoded text file. It should also work for any other encoding including UTF8. UTF8 is the default text file encoding used by Small Basic.
public static ReadANSI ( Primitive fileName ) : Primitive
fileName Primitive The file path to read.
return Primitive

ReadANSIToArray() public static method

Reads a text file with ANSI encoding into an array with one element for each line in the file. It should also work for any other encoding including UTF8. Blank lines are included as an element in the array with one blank space.
public static ReadANSIToArray ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

ReadCSV() public static method

Read a CSV (comma separated values) file into an array. The deliminator may be changed from a comma using Utilities.CSVdeliminator
public static ReadCSV ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the CSV file. ///
return Primitive

ReadCSVTransposed() public static method

Read a CSV (comma separated values) file into an array. and transpose (swap rows and columns). The deliminator may be changed from a comma using Utilities.CSVdeliminator
public static ReadCSVTransposed ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the CSV file. ///
return Primitive

ReadToArray() public static method

Reads a text file into an array with one element for each line in the file. Blank lines are included as an element in the array with one blank space.
public static ReadToArray ( Primitive fileName ) : Primitive
fileName Primitive /// The full path of the file. ///
return Primitive

RenameDirectory() public static method

Rename or move a directory.
public static RenameDirectory ( Primitive directoryFrom, Primitive directoryTo ) : Primitive
directoryFrom Primitive The full path to the directory to rename.
directoryTo Primitive The full path to the new name for the directory.
return Primitive

RenameFile() public static method

Rename or move a file.
public static RenameFile ( Primitive fileFrom, Primitive fileTo ) : Primitive
fileFrom Primitive The full path to the file to rename.
fileTo Primitive The full path to the new name for the file.
return Primitive

SaveAllVariables() public static method

Save all of the current variables to a file. This is the complete current state of your program. May be useful to store a game state, or for debugging.
public static SaveAllVariables ( Primitive fileName ) : void
fileName Primitive The full path to store the variables and their values. /// This file will be over-written.
return void

Size() public static method

Get the size of a file in bytes.
public static Size ( Primitive fileName ) : Primitive
fileName Primitive The full path to the file to get the size of.
return Primitive

WriteCSV() public static method

Write a 2D array to a CSV (comma separated values) file. The deliminator may be changed from a comma using Utilities.CSVdeliminator
public static WriteCSV ( Primitive fileName, Primitive array ) : void
fileName Primitive /// The full path of the CSV file. ///
array Primitive /// The array to export. ///
return void