Visual C++ Open/Save Dialog question

T

Tom Sapp

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
 
V

Victor Bazarov

Tom said:
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.
 
J

John Harrison

Tom said:
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
 
J

Jim Langston

Tom Sapp said:
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top