Below code is to create and write text to a text file
string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string fileLoc = mydocpath + @"\myEventLogSource_Pathwaytest.txt";
StreamWriter sw;
if (!File.Exists(fileLoc))
{
sw = new StreamWriter(File.Open(fileLoc, FileMode.Create)); }
else
{
sw = new StreamWriter(File.Open(fileLoc, FileMode.Append));
}
string fileLoc = mydocpath + @"\myEventLogSource_Pathwaytest.txt";
StreamWriter sw;
if (!File.Exists(fileLoc))
{
sw = new StreamWriter(File.Open(fileLoc, FileMode.Create)); }
else
{
sw = new StreamWriter(File.Open(fileLoc, FileMode.Append));
}
sw.Write("Hello");
sw.Dispose();
No comments:
Post a Comment