Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1172 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     .NET and MSSQL :

Visual Basic OpenFileDialog problem

Thread title: Visual Basic OpenFileDialog problem
Closed Thread    
    Thread tools Search this thread Display Modes  
08-10-2007, 02:53 PM
#1
Nightscream is offline Nightscream
Status: Junior Member
Join date: Aug 2006
Location:
Expertise:
Software:
 
Posts: 58
iTrader: 0 / 0%
 

Nightscream is on a distinguished road

  Old  Visual Basic OpenFileDialog problem

I got a problem with a visual basic script to get OpenFileDialog, to browse a filename
but always getting errors at the second line, something with As Stream.
Maybe you can fix this problem ^_^
(it's in access)

thanks in advance

Code:
Private Sub Bladeren_Click()
Dim myStream As Stream = Nothing
    
    Dim openFileDialog1 As New OpenFileDialog()

    openFileDialog1.InitialDirectory = "N:\"
    openFileDialog1.Filter = "All files (*.*)|*.*"
    openFileDialog1.FilterIndex = 1
    openFileDialog1.RestoreDirectory = True

    If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        Try
            myStream = openFileDialog1.OpenFile()
            If (myStream IsNot Nothing) Then
                ' Insert code to read the stream here.
                Voorbeeld = myStream
            End If
        Catch Ex As Exception
            MessageBox.Show ("Cannot read file from disk. Original error: " & Ex.Message)
        Finally
            ' Check this again, since we need to make sure we didn't throw an exception on open.
            If (myStream IsNot Nothing) Then
                myStream.Close()
            End If
        End Try
    End If
    
End Sub

08-15-2007, 02:21 AM
#2
amf is offline amf
Status: Member
Join date: Jul 2007
Location: Atlanta, GA (USA)
Expertise:
Software:
 
Posts: 108
iTrader: 0 / 0%
 

amf is on a distinguished road

  Old

Stream is too generic. Use FileStream instead. And you might also have to import System.IO.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed