string[] file = File.ReadAllLines(folder+"\\file.txt", Encoding.Default);
string result = file[1].Substring(1, file[1].Length - 1);
file[1] = file[1].Remove(1) + "MyText";
File.WriteAllLines(folder+"\\file.txt", file, Encoding.Default);
string path = @"c:\temp\MyTest.txt";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
File.WriteAllLines(folder+"\\file.txt", file, Encoding.Default);
sw.WriteLine(MyText2);
sw.WriteLine(MyText3);
}
}
// Open the file to read from.
int I = 0;
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
I++;
}
label1.Text = Convert.ToString(I);
и всё в лебеле у тебя кол-во строк - непустых
}
var lines = File.ReadAllLines(path);
var count = lines.Length - 1;
string[] file = File.ReadAllLines(path, Encoding.Default);
string result = file[count].Substring(file[count].Length);
file[count] = Settings.Default.realmlist;
File.WriteAllLines(path, file, Encoding.Default);