VB.net get files for 2 extensions added to listbox...

I am trying to add files names and path to a listbox. I have everything working, but  now I want to add 2 file extensions to each listbox not just one.

How can I make this work as I want?
My code is below...

Currently it only adds the first (.mpg) to the list and ignores .TS

Dim folderInfo7 As New IO.DirectoryInfo("X:\Encoded2\MCVOD\archive")
        Dim arrFilesInFolder7() As IO.FileInfo
        Dim fileInFolder7 As IO.FileInfo
        arrFilesInFolder7 = folderInfo7.GetFiles("*.MPG")
        Dim folderInfo8 As New IO.DirectoryInfo("X:\Encoded2\MCVOD\archive")
        Dim arrFilesInFolder8() As IO.FileInfo
        Dim fileInFolder8 As IO.FileInfo
        arrFilesInFolder8 = folderInfo8.GetFiles("*.ts")

 Form2.ProgressBar2.Value = 8
        Form2.Label2.Text = "Loading Content List For Archive Folder"
        For Each fileInFolder7 In arrFilesInFolder7

        Form2.ProgressBar2.Value = 9

        For Each fileInFolder8 In arrFilesInFolder8

Open in new window

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

DanielSVConnect With a Mentor Commented:
Have you tried stepping through the code using the debugger, to observe it's behaving the way you intend?

While debugging you can step through instruction for instruction, and keep track of what the variables contain at all times.

If you do this you'll see exactly what happens, and you'll get a good idea about how to fix it.

Also, you'd be better of using functions, instead of filesInFolder7 etc, etc.

PopulateListBox(ListBox8, Folder, Filetype)
Would be more elegant than copy-pasting a lot like your doing now.

Good luck :)
MaxDes101Author Commented:
I tried using the debugger, but it since my test system and production system are different I have to remove a ton of code just so it doesn't give me exceptions as soon as I load it. I even tried removing most of the code, but it still won't let me step over some things and gets stuck.

Also how would I view whats contained in a variable? The output window?
You would view it in the Locals/Watch windows. Also, you should avoid hard-coding all those paths :)

Regarding the watch window; have a look here: http://geekswithblogs.net/sdorman/archive/2009/02/14/visual-studio-2008-debugging-ndash-the-watch-window.aspx

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

MaxDes101Author Commented:
Well point being in the end I don't know how to change my code to get the result I want. I'm still learning and this has me confused. heh.

Debuggin is confusing me as well. I see immediate windows etc etc, but there are just lines of code it will not step over...

It's like the second variable that is supposed to be added to the listbox just never gets there.

I should avoid hardcoding those paths? Why is that? I need them hardcoded for my end result. These all load as a form load event.
Well, it's considered more elegant to load this from a config file, or take this as a start-parameter.

Anyways - what lines of code will it not step over? Use F10 to step one line at a time, and if you find a line it won't get past, it's waiting for a function to finish. In that case you should have stepped into it with F11 instead.

What lines of code is it the app stops at?
MaxDes101Author Commented:
I just removed ALL code except for the lines giving me issues....

Also in the debugging are I see f8
shift + f8
ctrl + shift + f8

but nothing about f10

I have the watch stuff worked out I think. Should I post it so you can see what  am seeing. I still am not seeing what the issue is...
MaxDes101Author Commented:
Ok, when I remove all the other code which are just copy and paste of the same thing it works fine with 1 test file of each extension. But when I add all the code back in it doesn't list the .ts files. Could this be something to do with the fact that I have the listbox set for sorting?
MaxDes101Author Commented:
I just switched the .ts for the .mpg just to switch the order and it's still not right. But I believe this has something to do with the file system and possibly the remote permissions. Thanks for all of your help.
All Courses

From novice to tech pro — start learning today.