我正在尝试覆盖现有的 XML 文件。如果文件存在,它不会被覆盖。我在这里检查一下。为什么不被覆盖。我错过了什么?
这是我的代码
Dim settings As New XmlWriterSettings()
settings.Indent = True
Dim FilePath As String = "\\server02\me_public$\audits\alert-special-reports.xml"
If Not File.Exists(FilePath) Then
Dim writer As XmlWriter = XmlWriter.Create(FilePath, settings)
writer.WriteStartDocument()
writer.WriteStartElement("audits")
writer.WriteStartElement("alert-special-reports")
writer.WriteElementString("title", "Alert and Special Reports")
writer.WriteElementString("rsslink", "http://www.me.org/rss/alert-special-reports.xml")
While dr.Read()
writer.WriteStartElement("item")
writer.WriteElementString("title", dr.GetString(dr.GetOrdinal("Title")))
writer.WriteElementString("description", dr.GetString(dr.GetOrdinal("Description")))
Dim dateNew As String = "", linkNew As String = ""
Dim DTNew As DateTime
Dim PDF As String = ""
DTNew = dr.GetDateTime(dr.GetOrdinal("PubDate"))
PDF = dr.GetString(dr.GetOrdinal("FilePath"))
dateNew = DTNew.ToLongDateString()
linkNew = "" & PDF & ""
writer.WriteElementString("link", linkNew)
writer.WriteElementString("pubdate", dateNew)
writer.WriteEndElement()
End While
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Flush()
writer.Close()
dr.Close()
End If