Jump to content
XpressMad

OpenFileDialog

Recommended Posts

XpressMad

eu queria buscar o caminho de uma imagem para depois utilizar o caminho

mas ao executar o programa quando carrego no butao que contem o codigo dame erro

este e o meu coodigo

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Title = "Selecione a imagem"
        OpenFileDialog1.InitialDirectory = "C:\imagens"
        OpenFileDialog1.ShowDialog()     'o erro é aqui'
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

        Dim strm As System.IO.Stream
        strm = OpenFileDialog1.OpenFile()
        TextBox1.Text = OpenFileDialog1.FileName.ToString()

    End Sub

Desde ja muito obrigado

Share this post


Link to post
Share on other sites
ribeiro55

E qual é o erro?

Isso que aí tens funciona.


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
Share on other sites
XpressMad

o erro que me da e este

"Tentativa de ler ou escrever na memória protegida. Isto é normalmente uma indicação de que existe outra memória danificada."

Share this post


Link to post
Share on other sites
ribeiro55

Hmm, só para despiste, experimenta da seguinte forma:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim OFD As New OpenFileDialog
    OFD.ShowDialog()
End Sub


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
Share on other sites
mateusb

o problema é do seu pc, fiz da maneira que disse, funcionou tudo direitinho!

Share this post


Link to post
Share on other sites
Ricardo80

isto ta parecendo problema de permissão, ja tentou ver as permissões da pasta?

ela esta no mesmo micro que vc esta tentando acessar ?

Share this post


Link to post
Share on other sites
XpressMad

eu ja tentei por no disco c mas nao deu, ja pus cm administrador e tambem nao deu, tem algum lugar que mais recomendado?

Share this post


Link to post
Share on other sites
XpressMad

o problema era que este codigo entra em conflito com uma datagriveview que eu tinha

obrigado a todos ;D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.