|
-
March 25th, 2010, 01:22 AM
#1
Multi-select file dialog
OK I'm having a strange problem with a CFile dialog which allows multiple selections. It's an open dialog. And when the user selects multiple files I use this code to enumerate the files and add their paths to a list control...
Code:
POSITION pos = openDlg.GetStartPosition();
while(pos)
{
CString pathName = openDlg.GetNextPathName(pos);
m_cSourceFiles.AddString(pathName);
}
the weird part is that when I select multiple files from the root of a drive the path will have two slashes in front of the file name like so...
F:\\Test.txt
If I select a file from a sub directory it works fine.
I know I can do a simple find and replace to fix it, but why is it doing this in the first place? Is this a bug in the CFileDialog code? Or something I'm doing wrong. Can anyone else able to reproduce this?
Thanks,
Dan
P.S. If it matters I'm using VS2005
-
March 25th, 2010, 04:48 AM
#2
Re: Multi-select file dialog
 Originally Posted by Dan203
...
P.S. If it matters I'm using VS2005
It would be more interesting which OS (Windows) version are you using?
-
March 25th, 2010, 07:17 AM
#3
Re: Multi-select file dialog
Yes, I get that too in Windows 7, but I don't know why it is like that.
-
March 25th, 2010, 07:45 AM
#4
Re: Multi-select file dialog
pathName.Replace("\\\\", "\\");
the problem with that is that it'll also replace the double backslash at the start of an UNC filename. So it needs to be a bit more than just that.
-
March 25th, 2010, 07:56 AM
#5
Re: Multi-select file dialog
In previous versions of Windows, using those double slashes with other Win32 API functions was not a problem. However, in Windows 7, using double slashes with certain functions will not work, so you will have to normalize your path somehow to get rid of those double slashes, except of course the double slash at the beginning of UNC names like OReubens mentioned.
-
March 25th, 2010, 01:59 PM
#6
Re: Multi-select file dialog
My machine is Win7 but I had some customers complain about this happening in XP as well.
I used...
pathName.Replace(":\\\\", ":\\");
to fix it, that way it'll only get drive paths and not UNC paths. I'm just glad to hear this is a universal problem and not something weird with my app.
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|