Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to convert filename to fully qualified name when running an app with a filename argument in the current working directory

How to convert filename to fully qualified name when running an app with a filename argument in the current working directory

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++jsonquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erik
    wrote on last edited by
    #1

    Hi, I am writing a commandline app that accepts a filename as parameter, and wonder if there is an easy way to convert the filename to a fully qualified filename when starting the app within a directory, and provide a filename that is located in the current working directory. for example, my app is located in c:\test\myapp.exe, and the file infile.txt is located there as well. So a user can call myapp.exe infile.txt from that directory. In my app, I'd like to be infile.txt converted to c:\test\infile.txt. Is there a function in the Win API or MFC that automatically expands filenames to full qualified path? Next step would be to allow relativ paths as well. Any hint how to do that? Thanks alot.

    _ 1 Reply Last reply
    0
    • E Erik

      Hi, I am writing a commandline app that accepts a filename as parameter, and wonder if there is an easy way to convert the filename to a fully qualified filename when starting the app within a directory, and provide a filename that is located in the current working directory. for example, my app is located in c:\test\myapp.exe, and the file infile.txt is located there as well. So a user can call myapp.exe infile.txt from that directory. In my app, I'd like to be infile.txt converted to c:\test\infile.txt. Is there a function in the Win API or MFC that automatically expands filenames to full qualified path? Next step would be to allow relativ paths as well. Any hint how to do that? Thanks alot.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      I'm not entirely sure, but check if the PathResolve API does the job for you. If not, you could maybe call GetCurrentDirectory and then append the filename to it.

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++)

      Polymorphism in C

      E 1 Reply Last reply
      0
      • _ _Superman_

        I'm not entirely sure, but check if the PathResolve API does the job for you. If not, you could maybe call GetCurrentDirectory and then append the filename to it.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        E Offline
        E Offline
        Erik
        wrote on last edited by
        #3

        Hi, thanks for your hints, I have also searched in the MSDN Lib myself, and have come to the conclusion that GetFullPathName works best for me, since it automatically expands a given filename to the full path. That was exactly what I wanted, and it works. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups