Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...