Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > Windows Forms

Windows Forms Discussion related to Winforms application development

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 12:24 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jul 2009
Age: 19
Posts: 6
Reputation: 0
bigklaxer is on a distinguished programming path ahead
Question Trouble Opening Files

I'm currently working on an application that allows users to select picture files and then categorize them into folders. Now I'm having two issues that are probably simple to fix but I only have a year of experience with vb so I just don't know how to fix them. The first and biggest issue is that once the user has selected and categorized a file, I want the program to select the next file in the folder that the first file was moved from. This way the number of clicks required is minimized. However I have no clue what I would need to do in order to accomplish this.

Also, my other problem is that I want to be able to find the indexof a quotation mark but whenever I put it in the parameter it just reads it as a quote. If anyone could help with these problems that would be fantastic.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 1:16 PM
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

Not sure about #1 yet but you could do this for
#2
Code:
    Dim strTest As String = "He said ""Help me please"""

        Dim intIndex As Integer = strTest.IndexOf(ControlChars.Quote)
__________________
If someone has helped you please rate them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-09-2009, 1:17 PM
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

How are you keeping track of the files? Are you using a list, a table, etc.. ? Some code for #1 would help us out.
__________________
If someone has helped you please rate them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-09-2009, 2:11 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jul 2009
Age: 19
Posts: 6
Reputation: 0
bigklaxer is on a distinguished programming path ahead
Default

Well basically what happens is in the designer the user selects an image file they want to move using an open file dialog and the image is displayed in a picture box. Then they select a folder for it to be moved into using a folder browser dialog. The program then moves the file to the selected folder. The program works fine and they could just continue selecting a new file but I want to make it easier and have the program automatically open the next file in the folder that the original file they selected was located in. Here's the code to move the file.

System.IO.File.Move(txtLocation.Text, txtDirectory.Text & folderName & newName & ".jpg")

Btw, thanks a ton for the help on #2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-09-2009, 3:06 PM
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 6:09 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.