简体   繁体   中英

Open a PDF existing file then save it in to a specific folder in VB.NET

I have existing code here, but it shows a SaveAs dialog immediately and this is quite confusing for some users. How can I improve this?

Dim write As StreamWriter
SaveFileDialog1.Filter = "PDF Files |*.pdf"
SaveFileDialog1.ShowDialog()
write = File.AppendText(SaveFileDialog1.FileName)
write.WriteLine()
write.Close()

If you want us to help you change how the user interface works, we need to see more context from that interface, and you need to talk to your users more about what they expected instead of the SaveAs dialog.

But we can help improve this code some:

SaveFileDialog1.Filter = "PDF Files |*.pdf"
If SaveFileDialog1.ShowDialog() = DialogResult.OK AndAlso Not String.IsNullOrWhitespace(SaveFileDialog1.FileName) Then    
    Using writer As StreamWriter = File.AppendText(SaveFileDialog1.FileName) 
        writer.WriteLine()
    End Using
End If

Based on the question title, maybe you wanted to show an OpenFileDialog first? Have you tried that? And then maybe a FolderBrowserDialog instead of SaveFileDialog ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM