TheWizardofInt Posted June 20, 2005 Posted June 20, 2005 I use this code to convert a string to a file: Private Function MakeFile(ByVal s As String) As String Dim sPath As String Dim sw As IO.StreamWriter If Not IO.Directory.Exists(Server.MapPath("./documents")) Then IO.Directory.CreateDirectory(Server.MapPath("./documents")) End If sPath = Server.MapPath("./documents") & "\transfer.xml" sw = New System.IO.StreamWriter(sPath, True) sw.Write(s) sw.Flush() sw = Nothing Return sPath End Function It creates the file, but doesn't release it. When I try to access the file, it is 'in use by another program' until I reset IIS Anyone seen this before? Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
samsmithnz Posted June 20, 2005 Posted June 20, 2005 I use this code to convert a string to a file: Private Function MakeFile(ByVal s As String) As String Dim sPath As String Dim sw As IO.StreamWriter If Not IO.Directory.Exists(Server.MapPath("./documents")) Then IO.Directory.CreateDirectory(Server.MapPath("./documents")) End If sPath = Server.MapPath("./documents") & "\transfer.xml" sw = New System.IO.StreamWriter(sPath, True) sw.Write(s) sw.Flush() sw = Nothing Return sPath End Function It creates the file, but doesn't release it. When I try to access the file, it is 'in use by another program' until I reset IIS Anyone seen this before? Try calling the Close() method. Quote Thanks Sam http://www.samsmith.co.nz
TheWizardofInt Posted June 20, 2005 Author Posted June 20, 2005 Oh, I cannot freaking believe I did that I reuse this code all of the time and I didn't check it Thanks for the fresh set of eyes Quote Read the Fovean Chronicles Because you just can't spend your whole day programming!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.