我是一个初学者,试图类似地复制微软的记事本,但我收到了这条消息。目前,我正在尝试对 ToolStripMenu 中的“新”项目进行编码。小结: 到目前为止,如果用户按下“新建”,系统会提示他们“是否要保存对此文档所做的更改?”,他们可以选择“否”,清除文档中的信息,或者选择“取消”,返回他们按计划回到原来的位置。但是,按“是”会给我错误“ArgumentException 未处理 - 空路径名不合法”
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
Dim intResult As Integer = Nothing
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Filter = "Text File (*.txt)|*.txt"
intResult = MessageBox.Show("Do you want to save the changes made to this document?", "Warning", MessageBoxButtons.YesNoCancel)
If intResult = Windows.Forms.DialogResult.Yes Then
RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText)
ElseIf intResult = Windows.Forms.DialogResult.No Then
RichTextBox1.Clear()
Else
Return
End If
End Sub