vb.net读写xml:VB.NET2005 读写文本文

Public Shared Function MFC_FSTextFileRead(ByVal FilePath_Name As String) As String
    Try
      If Dir(FilePath_Name) <> "" Then
        Dim FileReader As .IO.FileStream = .IO.File.Open(FilePath_Name, .IO.FileMode.Open)
        Dim FileByte(FileReader.Length - 1) As Byte
        FileReader.Read(FileByte, 0, FileReader.Length)
        Dim MyEncoder As .Text.Encoding = .Text.Encoding.Default
        MFC_FSTextFileRead = New String(MyEncoder.GetChars(FileByte))
        FileReader.Close
      Else
        Return ""
      End If
    Catch ex As Exception
      Return ""
    End Try
  End Function
  Public Shared Sub MFC_TextFileWrite(ByVal FilePath_Name As String, ByVal tmp As String)
    Dim stW As .IO.StreamWriter
    Dim FS As .IO.FileStream
    Try
      If Dir(FilePath_Name) <> "" Then
        FS = New .IO.FileStream(FilePath_Name, .IO.FileMode.Append)
      Else
        FS = New .IO.FileStream(FilePath_Name, .IO.FileMode.CreateNew)
      End If
      stW = New .IO.StreamWriter(FS)
      stW.WriteLine(tmp)
      stW.Close
    Catch ex As Exception
    End Try
  End Sub


Tags:  vb.netsql2005 vb.net2005教程 vb.net2005 vb.net读写xml

延伸阅读

最新评论

发表评论