string fileName = @"C:\adi.txt";
if (!File.Exists(fileName))
{
string startText = "File content" + Environment.NewLine;
lblerror.Text = startText;
File.WriteAllText(fileName, startText);
File.WriteAllText(fileName, "Add more content \n");
}
string appendText = "New appened text" + Environment.NewLine;
File.AppendAllText(fileName, appendText);
string data = File.ReadAllText(fileName);
Console.WriteLine(data);
if (!File.Exists(fileName))
{
string startText = "File content" + Environment.NewLine;
lblerror.Text = startText;
File.WriteAllText(fileName, startText);
File.WriteAllText(fileName, "Add more content \n");
}
string appendText = "New appened text" + Environment.NewLine;
File.AppendAllText(fileName, appendText);
string data = File.ReadAllText(fileName);
Console.WriteLine(data);
No comments:
Post a Comment