C
cj
Can someone help me convert this to vb please?
private void CreateLogFile()
{
StreamWriter sw = null;
try
{
sw = new StreamWriter(@"D:\Samples\Test.txt",
true, System.Text.UTF8Encoding.UTF8);
sw.WriteLine("This is some text");
}
finally
{
if (sw != null)
{
sw.Close();
}
}
}
I'm stuck on "StreamWriter sw = null;" I think it should be "Dim sw as
streamwriter" but how do I set it to null so I can check to see if it
was opened or not in the finally block?
private void CreateLogFile()
{
StreamWriter sw = null;
try
{
sw = new StreamWriter(@"D:\Samples\Test.txt",
true, System.Text.UTF8Encoding.UTF8);
sw.WriteLine("This is some text");
}
finally
{
if (sw != null)
{
sw.Close();
}
}
}
I'm stuck on "StreamWriter sw = null;" I think it should be "Dim sw as
streamwriter" but how do I set it to null so I can check to see if it
was opened or not in the finally block?