View Single Post
  #5 (permalink)  
Old 07-09-2009, 3:06 PM
demausdauth demausdauth is offline
VB.NET Forum Genius
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2008
Location: Minnesota
Posts: 214
Reputation: 210
demausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shamedemausdauth puts e.f. hutton to shame
Default

I used an OpenFileDialog control to get the intial file(s) and a FolderBrowserDialog control to determine where to send the files. I used a CheckBox to determine whether I was processing a single file or multiple files. Right now it asks each time for where to put the files, it could be easily modified to store the initial folder path and then use that for each repetition. How it determines how many files it is to process could be easily modified base on your criteria, also.
Well here's a start on #2 for you:

Code:

    Private Sub btnGetImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetImage.Click

        'get initial filelist
        ofdOpenFile.InitialDirectory = "C:\"
        ofdOpenFile.Filter = "Image Files (*.bmp,*.jpg,*.gif,*.png)|*.bmp;*.jpg;*.gif;*.png|All Files (*.*)|*.*"
        ofdOpenFile.FilterIndex = 1
        ofdOpenFile.Multiselect = False

        If ofdOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then

            'get initial filelist
            If chkProcessMultipleFiles.Checked Then
                'process all the files in the folder

                Dim ListOfFiles As New ArrayList
               

                Dim di As New IO.DirectoryInfo(IO.Path.GetDirectoryName(ofdOpenFile.FileName))

                ListOfFiles.AddRange(di.GetFiles("*.jpg"))
                ListOfFiles.AddRange(di.GetFiles("*.bmp"))
                ListOfFiles.AddRange(di.GetFiles("*.png"))
                ListOfFiles.AddRange(di.GetFiles("*.gif"))

                For FileCnt As Integer = 0 To ListOfFiles.Count - 1
                    If Not ProcessNextFile(ListOfFiles(FileCnt).ToString) Then
                        'stop processing files
                        Exit For
                    End If
                Next
            Else
                'process the single selected file

                ProcessNextFile(ofdOpenFile.FileName)

            End If


        End If
    End Sub

    Private Function ProcessNextFile(ByVal FilePathAndName As String) As Boolean

        'find out where to move it to
        fbdSaveToFolder.Description = "Select the folder to save the image " & Environment.NewLine & IO.Path.GetFileName(FilePathAndName)
        fbdSaveToFolder.RootFolder = Environment.SpecialFolder.MyComputer


        If fbdSaveToFolder.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
            Return False
        End If

        'move file to path selected
        My.Computer.FileSystem.MoveFile(FilePathAndName, _
        My.Computer.FileSystem.CombinePath(fbdSaveToFolder.SelectedPath, IO.Path.GetFileName(FilePathAndName)))

        Return True

    End Function
__________________
If someone has helped you please rate them.
Reply With Quote