Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication8
- {
- class Program
- {
- static void Main(string[] args)
- {
- string Filename = "text.txt";
- int lastStr = 0;
- try
- {
- if (File.Exists(Filename))
- {
- StreamReader sr = new StreamReader(Filename);
- string line;
- int lastLine = 0;
- // string resultStr = "";
- while ((line = sr.ReadLine()) != null)
- {
- if (line == "")
- continue;
- line = line.Replace(" ", "");
- if (Char.IsDigit(line[0]))
- {
- if (line[1] == '.')
- lastLine = line[0] - '0';
- else if (Char.IsDigit(line[1]))
- {
- if (line[2] == '.')
- {
- lastLine = Convert.ToInt16(string.Concat(line[0],line[1]));
- }
- }
- }
- }
- lastStr = lastLine;
- sr.Close();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Exception type is {0} \n", e.GetType());
- }
- try
- {
- StreamWriter sw = new StreamWriter(Filename, true);
- int j = 1;
- for (int i = lastStr + 1; i < lastStr + 1+10; i++, j++)
- {
- sw.WriteLine(i.ToString() + ". " + "Some text " + j);
- }
- sw.Close();
- }
- catch (Exception e)
- {
- Console.WriteLine("Exception type is {0} /n", e.GetType());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement