Last post Sep 19, 2011 03:46 PM by rossmc1
Sep 19, 2011 04:19 AM|Lybra|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 06:50 AM|TP|LINK
you should be using this to dispose the object implicitly.
using (StreamWriter writer = new StreamWriter("important.txt"))
Sep 19, 2011 03:46 PM|rossmc1|LINK
usually close or dispose is enough.