private void TestBigFileDump_File(string BIG_FILE, string FOLDER_PATH_FOR_CHUNK_FILES) { // Start processing the input Big file. StreamReader reader = new StreamReader(BIG_FILE); // Create a dump file class object to handle efficient memory management. var bigFileDumper = new BigFileDumper(FOLDER_PATH_FOR_CHUNK_FILES); // Reverse the list of commands as we would want the deepest leaf folder to be processed first. bigFileDumper.ReverseIt = true; bigFileDumper.CHUNK_SIZE = 100; // How much at a time to keep in RAM before dumping to local file. while (reader.EndOfStream == false) { string line = reader.ReadLine(); bigFileDumper.WriteLine(line); } bigFileDumper.Close(); reader.Close(); // Get back full reversed file. var reversedFilename = bigFileDumper.GetFullFile(); Console.WriteLine("Check output file - " + reversedFilename); // Delete the temporary folders. bigFileDumper.CleanEverything(); }
private void WriteTheBatchFile(ref BigFileDumper bigFileDumper) { // Read from the big file. string bigFile = bigFileDumper.GetFullFile(); if (!File.Exists(bigFile)) { MessageBox.Show("Something Went Wrong, no tempFile Generated."); return; } var bigFileReader = new StreamReader(bigFile); // Make the output bat file file ready. StreamWriter writer = new StreamWriter(batOutputFile); // First line is to change to working directory. writer.WriteLine("cd " + tbxMappedFolder.Text); writer.WriteLine(tbxMappedFolder.Text.Substring(0, 2)); string echoline = ""; int count = 0; long totalcount = bigFileDumper.TotalLineCount; while (!bigFileReader.EndOfStream) { // Echo line at each 10th folder. count++; if (count % 10 == 0) { echoline = String.Format("echo ********** {0} of {1} FOLDERS UPDATED ***********", count, totalcount); writer.WriteLine(echoline); } writer.WriteLine(bigFileReader.ReadLine()); } writer.Close(); bigFileReader.Close(); // Delete the temporary folders. bigFileDumper.CleanEverything(); }