vb.net与XmlTextWriter一起使用saveFileDialog

时间:2018-11-14 13:43:43

标签: vb.net

我是VB.net的新手

并且我设法使用

将输入写入xml文件
Dim writer As New XmlTextWriter("xmlInputFile.xml", System.Text.Encoding.UTF8)

现在我希望用户写他们自己的xml文件的名称和路径位置。 阅读了几个SaveFileDialog的示例,我给出了这段代码

Dim path As String = IO.Path.GetFullPath(SaveFileDialog1.FileName)
    Dim writer As New XmlTextWriter(ToString(path), System.Text.Encoding.UTF8)

出现错误

谢谢

下面的按钮代码

Private Sub Button3_Click_3(sender As Object, e As EventArgs) Handles btnSave.Click
    Dim SaveFileDialog1 As SaveFileDialog = New System.Windows.Forms.SaveFileDialog
    SaveFileDialog1.DefaultExt = ".xml"
    SaveFileDialog1.Filter = "XML files(.xml)|*.xml|all Files(*.*)|*.*"
    SaveFileDialog1.InitialDirectory = "desktop"

    If SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
        Save_Data()
    End If


End Sub

0 个答案:

没有答案