/// <summary> /// initlaize the two lists (Audoi_files,Folders) /// </summary> /// public static void Initlaize(string FileName1, string FileName2) { //Reading From AudiosInfo .. FileStream fs = new FileStream(FileName1, FileMode.Open); StreamReader sr = new StreamReader(fs); //Reading the first line in the File which contain the Nember of Audios Files.. string num_of_records = sr.ReadLine(); //Converting the string value into int by using TypeCasting.. num_of_rec = (int)num_of_records[0] - '0'; //Makeing Array of string to hold the Data from File to split it.. string[] records = new string[num_of_rec]; //Makeing a Temp Variable to hold the Data and push it in the List.. //Loop to Get the Data and split it.. for (int i = 0; i < num_of_rec; i++) { Audoios aud = new Audoios(); records = sr.ReadLine().Split(' '); aud.name = records[0]; string[] temp = records[1].Split(':'); aud.hourse = int.Parse(temp[0]); aud.min = int.Parse(temp[1]); aud.sec = int.Parse(temp[2]); aud.total_in_sec = aud.hourse * 3600 + aud.min * 60 + aud.sec; aud.index = i + 1; Audoi_files.Add(aud); } //Closing the Folder after Geting the Data.. sr.Close(); //Reading from Readme to konw the Max_Size of Folder.. FileStream f = new FileStream(FileName2, FileMode.Open); StreamReader s = new StreamReader(f); s.ReadLine(); string[] Temp = new string[2]; string[] size = new string[2]; Temp = s.ReadLine().Split('='); size = Temp[1].Split(' '); //Closing the File after Reading from it.. s.Close(); ////Converting the string value into int by using TypeCasting.. max_size = int.Parse(size[1]); }
public static void write(string Source, string Destination) { BaseOperations.Initlaize("AudiosInfo.txt", "readme.txt"); string path = Destination; if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); } int k = 1; string FileName = path; string source = Source; string destination = ""; int no = 0; int h = 0; while (BaseOperations.num_of_rec != 0) { int i = 0; path = Destination; source = Source; destination = ""; FileName = path; DirectoryInfo di; no = fill(0); if (no == 1) { for (int num = 0; num < BaseOperations.Audoi_files.Count; num++) { path = Destination; FileName = path; source = Source; path += @"\f" + k; di = Directory.CreateDirectory(path); source += @"\" + (BaseOperations.Audoi_files[num].index) + ".mp3"; destination = path + @"\" + (BaseOperations.Audoi_files[num].index) + ".mp3"; System.IO.File.Copy(source, destination); Console.WriteLine(source + " " + destination); FileName += @"\f" + k + "_MetaData.txt"; System.IO.FileStream F1 = new FileStream(FileName, FileMode.Create); StreamWriter w1 = new StreamWriter(F1); w1.WriteLine("f" + k); w1.WriteLine(BaseOperations.Audoi_files[num].name + " " + BaseOperations.Audoi_files[num].hourse + ":" + BaseOperations.Audoi_files[num].min + ":" + BaseOperations.Audoi_files[num].sec); w1.WriteLine(BaseOperations.Audoi_files[num].hourse + ":" + BaseOperations.Audoi_files[num].min + ":" + BaseOperations.Audoi_files[num].sec); w1.Close(); k++; i++; } return; } path += @"\f" + k; di = Directory.CreateDirectory(path); int w3 = 0; for (; i < no; i++) { source = Source; source += @"\" + (list[0][w3].index) + ".mp3"; destination = path + @"\" + (list[0][w3].index) + ".mp3"; System.IO.File.Copy(source, destination); w3++; } FileName += @"\f" + k + "_MetaData.txt"; System.IO.FileStream F = new FileStream(FileName, FileMode.Create); StreamWriter w = new StreamWriter(F); w.WriteLine("f" + k); Audoios tem = new Audoios(); for (int j = 0; j < no; j++) { w.WriteLine(list[0][j].name + " " + list[0][j].hourse + ":" + list[0][j].min + ":" + list[0][j].sec); tem.hourse += list[0][j].hourse; tem.min += list[0][j].min; tem.sec += list[0][j].sec; } w.WriteLine(tem.hourse + ":" + tem.min + ":" + tem.sec); k++; w.Close(); int var = 0; for (int it = 0; it < no; it++) { var = list[0][it].index - 1 - h; if (var < 0) { var = 0; } BaseOperations.Audoi_files.RemoveAt(var); h++; } BaseOperations.num_of_rec -= no; list[0].Clear(); list.Clear(); count = 0; } }