Wednesday 4 June 2014

Add Images in Listbox and copy from one directory to another directory using vb.net

 Dim path1 As String = "D:\scan"
                My.Computer.FileSystem.CreateDirectory(path1)
                Dim info As New DirectoryInfo(path1)
                If (info.Exists) Then
                    Dim file As FileInfo = Nothing
                    file = info.GetFiles.Last
                    If (file.Extension = ".png") Then
                        ListBox1.Items.Add(file.FullName)
                    End If
                    PictureBox1.ImageLocation = fileName
                    i = 0
====================================================

For index As Integer = 0 To ListBox1.Items.Count - 1
            Dim src1 As String = ListBox1.Items(index.ToString())
            If Directory.Exists("D:MyScan\") Then
                Dim f1 As String = Path.GetFileName(src1)
                dest1 = Convert.ToString("D:\MyScan\") & f1
                File.Copy(src1, dest1)
                PictureBox1.Image = Nothing
            Else
                Directory.CreateDirectory("D:\MyScan\")
                Dim f1 As String = Path.GetFileName(src1)
                dest1 = Convert.ToString("D:\MyScan\") & f1
                File.Copy(src1, dest1)
                PictureBox1.Image = Nothing
            End If

No comments:

Post a Comment

Followers