2013-03-02 47 views
2

我有一個名爲TextEditPro的程序,我剛開始它,我遇到了一個問題。如何在vb.net中使用savefiledialog

當我點擊另存爲的代碼...我不知道如何使用savefiledialog,所以當你點擊Save時它會彈出!

任何幫助?

回答

6

學習使用MSDN - 在documentationSaveFileDialog有一個例子

Private Sub button1_Click(sender As Object, e As System.EventArgs) 
    Dim myStream As Stream 
    Dim saveFileDialog1 As New SaveFileDialog() 

    saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" 
    saveFileDialog1.FilterIndex = 2 
    saveFileDialog1.RestoreDirectory = True 

    If saveFileDialog1.ShowDialog() = DialogResult.OK Then 
     myStream = saveFileDialog1.OpenFile() 
     If (myStream IsNot Nothing) Then 
      ' Code to write the stream goes here. 
      myStream.Close() 
     End If 
    End If 
End Sub 
+2

我只是張貼完全相同的代碼!呵呵 – PGallagher 2013-03-02 01:55:25