Visual C++ Open/Save Dialog question

Discussion in 'C++' started by Tom Sapp, Oct 29, 2005.

  1. Tom Sapp

    Tom Sapp Guest

    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
    Tom Sapp, Oct 29, 2005
    #1
    1. Advertising

  2. 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.
    Victor Bazarov, Oct 29, 2005
    #2
    1. Advertising

  3. 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
    John Harrison, Oct 29, 2005
    #3
  4. Take a look at splitpath and makepath in the MSDN.

    "Tom Sapp" <> wrote in message
    news:...
    > 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
    >
    Dave Townsend, Oct 29, 2005
    #4
  5. Tom Sapp

    Jim Langston Guest

    "Tom Sapp" <> wrote in message
    news:...
    >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;
    Jim Langston, Oct 29, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dGhleWFz?=
    Replies:
    8
    Views:
    6,548
    jilinjeevan
    Jan 29, 2008
  2. BusyBoy
    Replies:
    2
    Views:
    588
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 31, 2006
  3. hell2heaven
    Replies:
    0
    Views:
    407
    hell2heaven
    Oct 26, 2008
  4. Steve Sobol
    Replies:
    0
    Views:
    349
    Steve Sobol
    Jul 1, 2010
  5. eddie wang
    Replies:
    0
    Views:
    392
    eddie wang
    Oct 3, 2003
Loading...

Share This Page