0
我試圖覆蓋現有的XML文件來覆蓋和。如果文件存在,它不會被覆蓋。在這裏我檢查它。它爲什麼不被覆蓋。我錯過了什麼?如何使用現有的XML文件如果不File.Exists
這裏是我的代碼
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
仍然沒有工作什麼的,不知道我錯過了什麼。我刪除的文件,並將其複製罰款,沒有得到一個錯誤。它仍然不會覆蓋該文件。這真讓我抓狂。 – Gee
有人可以幫我這個或任何人都知道如何使用delet.file?我也試過這個也沒有。我試圖刪除它,它不工作。 Dim filePath As String =「\\ server02 \ file $ \ rss \ alert-special-reports2.xml」 If New New System.IO.FileInfo(filePath).Exists Then Then System.IO.File.Delete(filePath) 結束如果 – Gee
什麼是錯誤您收到?這可能是一些權限問題,你正在試圖寫一個網絡位置。 – Tariqulazam