VB.Net and XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viji
    New Member
    • Apr 2006
    • 1

    #1

    VB.Net and XML

    hi,

    i got an error "Illegal Character Path"
    my code as follows


    Code:
    Imports System.IO
    Imports System.Xml.Serialization
    Public Class serializabledata
        Public Function save(ByVal filename As String)
            Dim tempFilename As String
    
            tempFilename = filename & "*.tmp"
            Dim tempFileInfo1 As FileInfo
            Try
    
                tempFileInfo1 = New FileInfo(tempFilename)---------------illegal character path
            Catch e As Exception
                MsgBox(e.Message)     ----------
            End Try
    
            'If tempFileInfo1.Exists = True Then
            '    tempFileInfo1.Delete()
            'End If
    
            Dim stream As FileStream
            Try
                stream = New FileStream(tempFilename, FileMode.Create)---error: illegal character path
    
            Catch e As Exception
                MsgBox(e.Message)
            End Try
    
            save(stream)
            stream.Close()
            tempFileInfo1.CopyTo(filename, True)
            tempFileInfo1.Delete()
        End Function
    
        Public Function save(ByVal stream As Stream)
            Dim serializer As New XmlSerializer(Me.GetType)
            serializer.Serialize(stream, Me)
        End Function
    
    End Class
    Last edited by Dormilich; Jan 22 '09, 09:53 AM. Reason: added [code] tags
Working...