VB.NET读取 XML文件

来源:互联网 发布:台湾军舰误射导弹知乎 编辑:程序博客网 时间:2024/04/27 13:03
 '========================================================检测文件是否存在并创建
        Dim fs As Object
        fs = CreateObject("Scripting.FileSystemObject")
        If Not fs.fileexists("E:\flashgame\game\top.xml") Then
            MsgBox("错误提示:配置文件损坏,点击确定系统将重建配置文件。", MsgBoxStyle.OkOnly)


            Try
                Dim XmlWrite As System.Xml.XmlTextWriter = New System.Xml.XmlTextWriter("E:\flashgame\game\top.xml", System.Text.Encoding.UTF8)
                XmlWrite.WriteStartDocument() '开始一个文档
                XmlWrite.WriteStartElement("Activities")
                XmlWrite.WriteStartElement("Activitie  title=''") '开始一个元素,根元素
                XmlWrite.WriteEndElement() '关闭元素root
                XmlWrite.WriteEndDocument() '文档结束
                XmlWrite.Flush() '刷新
                XmlWrite.Close() '关闭


            Catch ex As Exception


            End Try

            MsgBox("系统重建配置文件成功。", MsgBoxStyle.OkOnly)


VS 2010测试通过

0 0
原创粉丝点击