|
-
Nov 9th, 2003, 06:38 PM
#1
Thread Starter
New Member
Problem with compiling SaveAs code
I am trying to write the code for the Save As function in my program.
I can get the SaveDialogBox up, and if the filename exists, that part works OK, and if you hit Cancel, that works OK.
But the code won't compile because it sees FileMode and FileAccess as undeclared.
Also the FileNotFoundException doesn't seem to be part of this set, and is not recognized. What am I missing?
Anyone know?
If not, does anyone have any canned code to execute the SaveAs DialogBox?
Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click
Dim fileChooser As SaveFileDialog = New SaveFileDialog
Dim result As DialogResult = filechooser.ShowDialog
Dim fileName As String
Dim output As FileStream
fileChooser.CheckFileExists = False
If result = DialogResult.Cancel Then
Return
End If
fileName = fileChooser.FileName
If (fileName = "" OrElse fileName = Nothing) Then
MessageBox.Show("Invalid File Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Try
output = New FileStream(fileName, FileMode.OpenorCreate, FileAccess.Write)
Catch fileException As FileNotFoundException
MessageBox.Show("File Not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|