static void Main(string[] args) { const int linesPerFile = 10; string path = @"G:\Folder"; const string destinationFileName = @"G:\Folder\File-Part-{0}.txt"; //string fileName = "File"; var maxNumberOfFiles = 10; Stopwatch timer = new Stopwatch(); var fileCounter = 0; if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); } var destiNationFile = new StreamWriter(string.Format(destinationFileName, fileCounter + 1)); try { // foreach (var bank in BankAcoutNumbers.BANS.Take(100)) //{ var lineCounter = 0; string line; while (fileCounter <= maxNumberOfFiles) { timer.Start(); foreach (var bank in BankAcoutNumbers.BANS.Take(100)) { if (lineCounter % linesPerFile == 0) { //lineCounter = 0; destiNationFile.Flush(); destiNationFile.Dispose(); destiNationFile = new StreamWriter(string.Format(destinationFileName, fileCounter + 1)); fileCounter++; } destiNationFile.WriteLine(bank); lineCounter++; } fileCounter++; //} } timer.Stop(); // Console.WriteLine(BankAcoutNumbers.BANS.Count()); Console.WriteLine(timer.Elapsed.Seconds); } catch (Exception) { throw; } // Keep the console window open in debug mode. System.Console.WriteLine("Press any key to exit."); System.Console.ReadKey(); }
100000002 100000010 100000029 100000037 100000045 100000053 100000061 100000088 100000096 100000118
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)