Hey,
1. I have to create a file.
2. Then I want to write a string into the text file.
I can do part 1 no problem with:
File.Create(strFilePath)
But when I try part 2 to write to the file it won't allow this as it's still being used:
sw = File.AppendText(strFileName)
sw.WriteLine(strCode)
sw.Flush()
sw.Close()
My code in part 2 works fine on a file that hasn't just been created.
How do I release the file from the File object?
There doesn't seem to be a .close or .flush option...?
Thanks.
1. I have to create a file.
2. Then I want to write a string into the text file.
I can do part 1 no problem with:
File.Create(strFilePath)
But when I try part 2 to write to the file it won't allow this as it's still being used:
sw = File.AppendText(strFileName)
sw.WriteLine(strCode)
sw.Flush()
sw.Close()
My code in part 2 works fine on a file that hasn't just been created.
How do I release the file from the File object?
There doesn't seem to be a .close or .flush option...?
Thanks.