/// <summary> /// Load File from folder using index /// </summary> public static string LoadFile(int structIndex) { //load data WindowCSVData data = WindowCSVData.LoadData(); //load file using index return(LoadFile(data.StructCSV[structIndex])); }
/// <summary> /// Load File from folder using selected one in the window /// </summary> public static string LoadFile() { //load data WindowCSVData data = WindowCSVData.LoadData(); //load file using index in data return(LoadFile(data.StructCSV[data.IndexStruct])); }
/// <summary> /// Start Download from link /// </summary> public static void DownloadCSV() { //load data WindowCSVData data = WindowCSVData.LoadData(); //UnityWebRequest replace old WWW www = UnityWebRequest.Get(data.StructCSV[data.IndexStruct].LinkCSV); UnityWebRequestAsyncOperation request = www.SendWebRequest(); //wait download request.completed += OnCompleteDownload; //while (!request.isDone) { } }
/// <summary> /// Delete directory with every file /// </summary> public static void DeleteDirectory() { //load data WindowCSVData data = WindowCSVData.LoadData(); //check there is a directory if (Directory.Exists(data.StructCSV[data.IndexStruct].PathFolder) == false) { Debug.Log("Directory not found: " + data.StructCSV[data.IndexStruct].PathFolder); return; } //delete directory Directory.Delete(data.StructCSV[data.IndexStruct].PathFolder, true); Debug.Log("Directory deleted successfully: " + data.StructCSV[data.IndexStruct].PathFolder); }
/// <summary> /// Delete file /// </summary> public static void DeleteFile() { //load data WindowCSVData data = WindowCSVData.LoadData(); //check there is a file if (File.Exists(data.StructCSV[data.IndexStruct].PathFile) == false) { Debug.Log("File not found: " + data.StructCSV[data.IndexStruct].PathFile); return; } //delete file File.Delete(data.StructCSV[data.IndexStruct].PathFile); Debug.Log("File deleted successfully: " + data.StructCSV[data.IndexStruct].PathFile); }
/// <summary> /// Load File from folder looking in the list using StructName /// </summary> public static string LoadFile(string structName) { //load data WindowCSVData data = WindowCSVData.LoadData(); foreach (WindowCSVStruct structCSV in data.StructCSV) { //if found name if (structCSV.StructName.Equals(structName)) { return(LoadFile(structCSV)); } } return(null); }
/// <summary> /// Save downloaded File in folder /// </summary> /// <param name="value"></param> public static void SaveFile(string value) { //load data WindowCSVData data = WindowCSVData.LoadData(); //if there is no directory, create it if (Directory.Exists(data.StructCSV[data.IndexStruct].PathFolder) == false) { Directory.CreateDirectory(data.StructCSV[data.IndexStruct].PathFolder); } //create stream to file position StreamWriter writer = new StreamWriter(data.StructCSV[data.IndexStruct].PathFile); //then save value to file position, and close stream writer.Write(value); writer.Close(); }
void OnEnable() { //load data data = WindowCSVData.LoadData(); }