By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,034 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,034 IT Pros & Developers. It's quick & easy.

Visual C++ Open/Save Dialog question

P: n/a
I was wondering what the easiest way to get only the filename from the
FileName property of the Save/Open dialogs in Visual C++? I've create a
string variable and set it to SaveDialog1.FileName but that contains
the path and the filename. I know I could go through and find the first
\ from the end of the variable and remove anything before it but there
has to be an easier, less time consuming way, of doing this. In Delphi
there was a property of the Save/Open dialogs that would automatically
return only the filename and not the path, but, as far as I can tell,
there is not one for Visual C++. Any help and/or ideas would be greatly
appreciated!

Thanks,
Tom Sapp
http://www.sappsworld.com

Oct 29 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tom Sapp wrote:
I was wondering what the easiest way to get only the filename from the
FileName property of the Save/Open dialogs in Visual C++? [...]


Please ask in 'microsoft.public.vc.language' - the designated Visual
C++ newsgroup. 'comp.lang.c++' talks about standard C++, and it does
not have "Save/Open dialogs", which makes your query off-topic.
Oct 29 '05 #2

P: n/a
Tom Sapp wrote:
I was wondering what the easiest way to get only the filename from the
FileName property of the Save/Open dialogs in Visual C++? I've create a
string variable and set it to SaveDialog1.FileName but that contains
the path and the filename. I know I could go through and find the first
\ from the end of the variable and remove anything before it but there
has to be an easier, less time consuming way, of doing this.


Why? Is that really difficult? You sould like one of those programmers
who doesn't actually like programming.

If you wrote a function to do this it would be five lines long (at
most), would take you about 10 minutes, and then you would never have to
write that function again.

John
Oct 29 '05 #3

P: n/a
Take a look at splitpath and makepath in the MSDN.

"Tom Sapp" <ra****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I was wondering what the easiest way to get only the filename from the
FileName property of the Save/Open dialogs in Visual C++? I've create a
string variable and set it to SaveDialog1.FileName but that contains
the path and the filename. I know I could go through and find the first
\ from the end of the variable and remove anything before it but there
has to be an easier, less time consuming way, of doing this. In Delphi
there was a property of the Save/Open dialogs that would automatically
return only the filename and not the path, but, as far as I can tell,
there is not one for Visual C++. Any help and/or ideas would be greatly
appreciated!

Thanks,
Tom Sapp
http://www.sappsworld.com

Oct 29 '05 #4

P: n/a
"Tom Sapp" <ra****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I was wondering what the easiest way to get only the filename from the
FileName property of the Save/Open dialogs in Visual C++? I've create a
string variable and set it to SaveDialog1.FileName but that contains
the path and the filename. I know I could go through and find the first
\ from the end of the variable and remove anything before it but there
has to be an easier, less time consuming way, of doing this. In Delphi
there was a property of the Save/Open dialogs that would automatically
return only the filename and not the path, but, as far as I can tell,
there is not one for Visual C++. Any help and/or ideas would be greatly
appreciated!

Thanks,
Tom Sapp
http://www.sappsworld.com


What's so hard about that? If it's a std::string just use
find_last_of(...). If it's not a std::string, make it one.

std::string FullPath = CStringReturnedFromUglyWindowsCode;
Oct 29 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.