G
Guest
I can't get the following msdn code below to actually open the .txt file i
select
It seems
Return DlgOpenFile.OpenFile()
or
Return New FileStream(Path, System.IO.FileMode.Open, _
System.IO.FileAccess.ReadWrite)
don't actually do anything.
Please help as I need this working for my prototype tomorrow.
Private Function OpenFile() As FileStream
' Displays an OpenFileDialog and shows the read/only files.
Dim DlgOpenFile As New OpenFileDialog()
DlgOpenFile.ShowReadOnly = True
Dim Fs As FileStream
If DlgOpenFile.ShowDialog() = DialogResult.OK Then
' If ReadOnlyChecked is true, uses the OpenFile method to
' open the file with read/only access.
If DlgOpenFile.ReadOnlyChecked = True Then
Return DlgOpenFile.OpenFile()
' Otherwise, opens the file with read/write access.
Else
Dim Path As String = DlgOpenFile.FileName
Return New FileStream(Path, System.IO.FileMode.Open, _
System.IO.FileAccess.ReadWrite)
End If
End If
End Function
select
It seems
Return DlgOpenFile.OpenFile()
or
Return New FileStream(Path, System.IO.FileMode.Open, _
System.IO.FileAccess.ReadWrite)
don't actually do anything.
Please help as I need this working for my prototype tomorrow.
Private Function OpenFile() As FileStream
' Displays an OpenFileDialog and shows the read/only files.
Dim DlgOpenFile As New OpenFileDialog()
DlgOpenFile.ShowReadOnly = True
Dim Fs As FileStream
If DlgOpenFile.ShowDialog() = DialogResult.OK Then
' If ReadOnlyChecked is true, uses the OpenFile method to
' open the file with read/only access.
If DlgOpenFile.ReadOnlyChecked = True Then
Return DlgOpenFile.OpenFile()
' Otherwise, opens the file with read/write access.
Else
Dim Path As String = DlgOpenFile.FileName
Return New FileStream(Path, System.IO.FileMode.Open, _
System.IO.FileAccess.ReadWrite)
End If
End If
End Function