Class FileTools
Assembly: TowseyLibrary.dll
public static class FileTools
Methods
|
Improve this Doc
View Source
THis method adds another column to an existing .csv file containing columns of data.
It assumes that the number of elements in the list are same as rows in the existing file.
Declaration
public static void AddArrayAdjacentToExistingArrays(string fPath, double[] array)
Parameters
|
Improve this Doc
View Source
Append2TextFile(String, List<String>)
Declaration
public static void Append2TextFile(string fPath, List<string> list)
Parameters
|
Improve this Doc
View Source
Append2TextFile(String, String)
Declaration
public static void Append2TextFile(string fPath, string line)
Parameters
|
Improve this Doc
View Source
Append2TextFile(String, String, Boolean)
Declaration
public static void Append2TextFile(string fPath, string line, bool saveExistingFile)
Parameters
|
Improve this Doc
View Source
Declaration
public static string AppendToFileName(string ipPath, string appendix)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static bool BackupFile(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string ChangeFileExtention(string path, string newExt)
Parameters
Returns
|
Improve this Doc
View Source
CountLinesOfTextFile(String)
Declaration
public static int CountLinesOfTextFile(string fName)
Parameters
Type |
Name |
Description |
String |
fName |
|
Returns
|
Improve this Doc
View Source
Declaration
public static FileInfo[] GetFilesInDirectory(string dirPath)
Parameters
Type |
Name |
Description |
String |
dirPath |
|
Returns
|
Improve this Doc
View Source
Declaration
public static FileInfo[] GetFilesInDirectory(string dirPath, string ext)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static string PathCombine(params string[] paths)
Parameters
Type |
Name |
Description |
String[] |
paths |
|
Returns
|
Improve this Doc
View Source
reads a text file of doubles formatted in rows and columns.
Declaration
public static double[, ] ReadDoubles2Matrix(string fName)
Parameters
Type |
Name |
Description |
String |
fName |
|
Returns
|
Improve this Doc
View Source
reads a file of doubles assuming one value per line with no punctuation.
Declaration
public static double[] ReadDoubles2Vector(string fName)
Parameters
Type |
Name |
Description |
String |
fName |
|
Returns
|
Improve this Doc
View Source
Declaration
public static List<string> ReadSelectedLinesOfCsvFile(string fName, string key, int value)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static byte[] ReadSerialisedObject(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Returns
|
Improve this Doc
View Source
ReadTextFile(String)
Declaration
public static List<string> ReadTextFile(string fName)
Parameters
Type |
Name |
Description |
String |
fName |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string[] SplitFileName(string path)
Parameters
Type |
Name |
Description |
String |
path |
|
Returns
|
Improve this Doc
View Source
Declaration
public static string TimeStamp2FileName(DateTime datetime)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static string UrlCombine(params string[] segments)
Parameters
Type |
Name |
Description |
String[] |
segments |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void WriteArray2File(double[] array, string fName)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteArray2File(int[] array, bool addLineNumbers, string fName)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteArray2File_Formatted(double[] array, string path, string formatString)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteArray2File_Formatted(int[] array, string path, string formatString)
Parameters
|
Improve this Doc
View Source
Write a dictionary of arrays as a csv file where dictionary keys are column headers and the
arrays are the column entries.
WARNING: Assume that all arrays are of the same size!.
Declaration
public static void WriteDictionaryAsCsvFile(Dictionary<string, double[]> dictionary, string fPath)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteDictionaryToFile(Dictionary<string, double[]> dictionary, string fPath)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMatrix2File(char[, ] matrix, string fName)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMatrix2File(double[, ] matrix, string fName)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMatrix2File(int[, ] matrix, string fName)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteMatrix2File_Formatted(double[, ] matrix, string fName, string formatString)
Parameters
|
Improve this Doc
View Source
Declaration
public static void WriteSerialisedObject(string path, byte[] array)
Parameters
|
Improve this Doc
View Source
WriteTextFile(FileInfo, IEnumerable<String>, Boolean)
Declaration
public static void WriteTextFile(FileInfo path, IEnumerable<string> array, bool saveExistingFile = true)
Parameters
|
Improve this Doc
View Source
WriteTextFile(String, IEnumerable<String>, Boolean)
Declaration
public static void WriteTextFile(string path, IEnumerable<string> array, bool saveExistingFile = true)
Parameters
|
Improve this Doc
View Source
WriteTextFile(String, String)
Declaration
public static void WriteTextFile(string path, string text)
Parameters