Webservice doesn't release file

TheWizardofInt

Well-known member
Joined
Dec 31, 1969
Messages
333
Location
Orlando, FL
I use this code to convert a string to a file:

Code:
 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 doesnt release it. When I try to access the file, it is in use by another program until I reset IIS

Anyone seen this before?
 
TheWizardofInt said:
I use this code to convert a string to a file:

Code:
 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 doesnt 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.
 

Similar threads

J
Replies
0
Views
109
JenCarlos
J
F
Replies
0
Views
126
FabrizioLeoSanca
F
Back
Top