Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

rippp

Problema com o file.copy

Recommended Posts

rippp

boas,

Estou aqui com um problema com o file.copy que diz que "couldn't find a part of path". a pasta img é criada no directorio de debug mas quando copia da erro. Alguma sugestao ?

   Private Sub btImg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btImg.Click
        Try
            If Not IO.Directory.Exists("img") Then
                IO.Directory.CreateDirectory("img")
            End If

            OpenFileDialog.Title = "Procurar imagem"
            OpenFileDialog.ShowDialog()

            Dim conexaoBD As OleDbConnection
            conexaoBD = New OleDbConnection(ConnString)

            conexaoBD.Open()
            Dim SqlNumImg As String = "select Num_img from generica where id=1"
            Dim adaptadorDados As OleDbDataAdapter = New OleDbDataAdapter(SqlNumImg, conexaoBD)
            Dim dsdados As DataSet = New DataSet
            adaptadorDados.Fill(dsdados, "generica")

            Dim ImgNum As Integer = CInt(dsdados.Tables(0).Rows(0).Item("Num_img"))
            ImgNum = ImgNum + 1
            Dim SqlInsNum As String = "update generica set Num_img=" & ImgNum & " where id=1"
            Dim comandoSql As OleDbCommand = New OleDbCommand(SqlInsNum, conexaoBD)
            comandoSql.ExecuteNonQuery()
            Dim SqlInsert As String = "insert into imagem (CodProd,Imagem) values (" & Label4.Text & "," & ImgNum & ")"
            'IO.File.Copy(abc, "img\" & ImgNum.ToString & ".jpg", True)
            FileCopy(OpenFileDialog.FileName, "img\" & ImgNum & ".jpg")
            conexaoBD.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


    End Sub


Java, Android developerhttp://minimalcode.net

Share this post


Link to post
Share on other sites
ribeiro55

Nunca experimentei usar relative paths.

Experimenta com o absolute path:

Application.StartupPath & "\img\" & ImgNum & ".jpg"


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
rippp

sim ja tenho isso a funcionar o problema agora é que ele copia o ficheiro para a pasta certa mas o ficheiro abre sem pre visualizacao. nao consigo ver a imagem.

Ja esta tudo a funcionar


Java, Android developerhttp://minimalcode.net

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

×

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.