Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 19, 2011 07:46 PM by rossmc1
Sep 19, 2011 08:19 AM|LINK
I have a sub that copies and renames a file:
And since here everything is working fine, the file is copied succesfully!!!
The problem comes out when, after, in another sub, I try to write something inside the file copied because for vb the file is still being used!!!
So if I call:
sw = New StreamWriter(destfile)
I receive the error.
I can't kill the process because the process that's keeping the file in use is my app; what the simplest way to "close" the file?
Many thanks in advance for your help.
Sep 19, 2011 10:50 AM|LINK
you should be using this to dispose the object implicitly.
using (StreamWriter writer = new StreamWriter("important.txt"))
Sep 19, 2011 07:46 PM|LINK
usually close or dispose is enough.