FolderBrowserDialog crashes when path is too long

  • Thread starter Thread starter Lars-Erik Aabech
  • Start date Start date
L

Lars-Erik Aabech

Hi!

I'm kind of dissapointed right now :(
I've got a FolderBrowserDialog in my form, and it works fine, until I choose
a path that is over approximately 135 characters long. Then it crashes the
entire app. (Haven't got the exact count, but it works with ca. 130)
Is this behavior by design, or is it a bug? Anyway, it's really annoying.
The error that occurs is the following:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in mscorlib.dll
Additional information: Invalid access to memory location.

Any help appreciated!

Lars-Erik
 
I just ran a few tests and it looks like I can get it to work with up to 246
characters which is the maximum Windows is letting me get a away with. I'm
3 subdirectories down, and it just won't let me create anything else...it
tells me it can't create a file with the given extension, even though I'm
not creatinga file.

Now here's the weird part. If I use the long path names, everything is fine
until I try to close the app and then it tells me memory couldn't be
written. Only when I get really long path's does this happen. ALso, when I
go over appartently about 120+, I get occassional null reference exceptions,
but they are intermittent, only happen sometimes. I've done this about 10
times so far, and I can get to 158 no problem 8 of the times. Never had a
Null reference exception on the 246 one, but anything much over 100 gives me
the "Memory could not be written" thing.

Then, pretty consistently, if I try to attempt to reads of the long
filenames, I get the null reference with a "Infinite Recursion Attempted"
(happens intermittently as well) and occassionally I'm getting a DialogBox
before closing the app with a Memory error.

Since it's not consistent, but does appear to have problems consistently on
the second attempts....I'm guessing you are onto something with the bug
thing.

I looked around the net though and haven't seen anything about a Max length
or any combination of FolderBrowserDialog and the exception messages...

I'll post if I can find anything.

Cheers,

Bill
 
Hi,

The BrowserFolderDialog control is just a wrapper for the Windows API
function SHBrowserForFolder . This function takes a pointer to a BROWSEINFO
structure, where the maximum length of the path is defined to be MAX_PATH
(259 + 1 for NULL).

I've run some tests and I agree with you that this seems to be a bug.
Because .NET uses Unicode strings and the Windows API usually uses ANSI
strings, the bug could be related to the conversion or handling of the
strings.

BROWSEINFO Structure
http://msdn.microsoft.com/library/d...orm/shell/reference/structures/browseinfo.asp

Regards,

Gabriele
 
So what you're saying is that I have to do this with lowlvl stuff? :|

OMG!

yeah, well.. hack away :)

tnx..

L-E
 
Back
Top