View Full Version : OpenFileDialog


hooks
04-07-2006, 08:01 AM
Hey all. I am working on an MP3 player and am having the following problem when i am importing music from a directory.

What i am wanting to do is show a openfiledialog box and let the user select which tracks to add to the mp3 player.

Now i have a folder of mp3s with over 1133 mp3 files in them. When i highlight 1133 files and click the OK button in the openfiledialog i get the following message after a couple of seconds "File doesn't exists". Now i get this message for all files after the first file that doesn't exists.

I can rerun the procedure and just add the files that it said didn't exists the first time and it runs fine.

Its like there is a file limit or something and i cant figure it out.

With OpenFileDialog1
.Filter = "MP3 Files|*.mp3"
.Title = "Please select an MP3 file to open"
.Multiselect = True

.ShowDialog()
End With

MessageBox.Show(OpenFileDialog1.FileNames.Length.T oString)

'Get the MP3 tag information from track
Dim TrackFileNames() As String = OpenFileDialog1.FileNames
OpenFileDialog1 = Nothing

Dim TrackFileName As String
For Each TrackFileName In TrackFileNames
ReadTag(TrackFileName)
Next

'Update database



As always thanks a bunch

Kodo
04-07-2006, 11:59 PM
hard to say without seeing what readtag does, but in this view, we aren't seeing any file exists checking.. are you doing any checks on this? have you debugged and stepped through to make sure that the full path is going to the function ok?

hooks
04-08-2006, 09:16 PM
I have tried it with file exists checking and it still fails at the exact same file before the readtag procedure runs. Its like there is a file limit or something.

very strange.

Any ideas.

hooks
04-08-2006, 09:49 PM
OK i have a couple of folders with a bunch of mp3s. The first folder contains. 1133 files and i get the file doesn't exists at the 928th file

The next folder has 2000 files and i get the file doesn't exists at the 973rd file.

I cant figure this out and it is driving me mad. Why would it only find some of the files. Now on the first folder with 1133 files i can import the first 927 file and it work perfect. I can then add the remainder files without a problem. It just will not let me add them all at once.

Hooks

Kodo
04-09-2006, 09:33 PM
I bet it has to do with the collection size in bytes. You might have to limit the selection to like 300 at a time until a solution can be found.

Surjer
04-24-2006, 08:29 AM
what line of code throws the exception?

hooks
04-24-2006, 03:28 PM
Im at work at the moment. Give me about 10 hours and ill give you more details.

Surjer
04-25-2006, 05:37 AM
ok time is up! lol

hooks
04-25-2006, 06:06 AM
ok time is up! lol LOL

Here is more details

With Me.OpenFileDialog1
.Multiselect = True
.CheckFileExists = True
.Filter = "MP3 Files|*.mp3"
.Title = "Please select MP3 to add to playlist"
End With

If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

Dim files() As String = Me.OpenFileDialog1.FileNames

For Each file As String In files ' using the new 1.1 syntax
ReadTag(file)
Next
End If


Im getting the file doesn't exist in the If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then line of code. I can get it to go past this line if i turn off the checkfileexist = false but my code still fails on the exact same file even though the file is there.

Im able to add about 900 tracks which equals about 4 gig. It seems like there is a file size limit or something. Anything past this number and i get the file doesn't exist error.

What i have done for a quick and dirty solution is use a FolderBrowserDialog so that the user can add all tracks in a folder no matter how many tracks are in that folder. I don't like this solution though.

Anyone have any ideas on how to do this without using a folderbrowserdialog.

As always thanks a bunch

Hooks

Surjer
04-26-2006, 05:38 AM
Can you add a watch to the variable "FileNames" and check its contents after selecting all your files? - Maybe you can see if the control is returning bad data. I would switch to API instead of ActiveX anyways...

Kodo
04-26-2006, 11:16 AM
this is not the same error message but it could be another related issue
http://support.microsoft.com/kb/820631

hooks
04-26-2006, 02:00 PM
Can you add a watch to the variable "FileNames" and check its contents after selecting all your files? - Maybe you can see if the control is returning bad data. I would switch to API instead of ActiveX anyways...

It doesn't make it to the filenames variable. It fails when i do showdialog.
Actually it doesn't fail but it gives me the file doesn't exists message.

Can you give me an example of opening a file dialog using API???

Thanks
both of ya.

Surjer
04-26-2006, 02:04 PM
Search is our friend lol
http://www.access-programmers.co.uk/forums/showthread.php?t=97787&highlight=common+dialog+API

hooks
04-26-2006, 07:16 PM
Search is our friend lol
http://www.access-programmers.co.uk/forums/showthread.php?t=97787&highlight=common+dialog+API


I assume that this works the same way in vb.net??

Nevermind ill search :)

Thanks