'========================================================检测文件是否存在并创建
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测试通过