Create text file using File.CreateText
using System;
using System.IO;
class MainClass
{
static void Main(string[] args)
{
StreamWriter MyStream = null;
string MyString = "Hello World";
try
{
MyStream = File.CreateText("MyFile.txt");
MyStream.Write(MyString);
}
catch (IOException e)
{
Console.WriteLine(e);
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
if (MyStream != null)
MyStream.Close();
}
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
|