first i create 1 form, 1 picture box and 1 button..

i name button like upload...when i click upload button, i can browse picture..so after i click a picture,automaticly picture will set in picture box and 1 folder like mypicture will be create on C:// and that picture will be transfer into mypicture folder..

Recommended Answers

All 4 Replies

' this for create folder at c:\MyPicture\
If (Not System.IO.Directory.Exists("C:\MyPicture")) Then
    System.IO.Directory.CreateDirectory("C:\MyPicture")
End If

'this for open file in picture box
    Dim OpenFileDialog1 As New OpenFileDialog
    With OpenFileDialog1
        .CheckFileExists = True
        .ShowReadOnly = False
        .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
        .FilterIndex = 2

        If .ShowDialog = DialogResult.OK Then
            ' Load the specified file into a PictureBox control.
            PictureBox1.Image = Image.FromFile(.FileName)
        End If
    End With
	
' this for copying file
If System.IO.File.Exists(SourcePath) = True Then
    File.Copy(SourcePath, DestinationPath, True)
End If

where i have to put this code & how to declare SourcePath,DestinationPath & SourcePath

If System.IO.File.Exists(SourcePath) = True Then
File.Copy(SourcePath, DestinationPath, True)
End If

See if this helps with explaining a little about "SourcePath" and "DestinationPath".

If .ShowDialog = DialogResult.OK Then
                ' Load the specified file into a PictureBox control.
                PictureBox1.Image = Image.FromFile(.FileName)
                If IO.File.Exists(.FileName) = True Then '// check if file exists by using the FullPath of the file.
                    IO.File.Copy(.FileName, "C:\MyPicture\" & IO.Path.GetFileName(.FileName), True) '//  IO.File.Copy(SourcePath, DestinationPath, Overwrite)
                    '// IO.Path.GetFileName(.FileName) only gets the FileName and Extension of a file and not the FullPath like when using only ".FileName".
                    MsgBox("File Copy Successful.")
                End If
            End If

SourcePath is the original FullPath of a file and DestinationPath is the new FullPath for the file.

arezz09 : codeorder give the complete guide :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.