public static Dictionary<String, int> DivisionFile(String filename, long maxCountChar, int sizeOneLine) { Dictionary<String, int> result = new Dictionary<string, int>(); Part part = new Part(); part.initializeStream(filename); string currentLine; StreamReader streamWriter = null; try { streamWriter = new StreamReader(filename); while ((currentLine = streamWriter.ReadLine()) != null) { part.stream.WriteLine(currentLine); part.size += sizeOneLine; if (part.size > maxCountChar - sizeOneLine) { result.Add(part.PartName, part.size); part.stream.Close(); part.number++; part.size = 0; part.initializeStream(filename); } } result.Add(part.PartName, part.size); part.stream.Close(); } catch (FileNotFoundException e) { throw e; } finally { if (streamWriter != null) { streamWriter.Close(); } } return result; }