Jump to content

Problema com o file.copy


Recommended Posts


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
            If Not IO.Directory.Exists("img") Then
            End If

            OpenFileDialog.Title = "Procurar imagem"

            Dim conexaoBD As OleDbConnection
            conexaoBD = New OleDbConnection(ConnString)

            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)
            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")
        Catch ex As Exception
        End Try

    End Sub

Java, Android developerhttp://minimalcode.net

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
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.