'========================================================檢測檔案是否存在并建立
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測試通過