How to convert filename to fully qualified name when running an app with a filename argument in the current working directory
-
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.
-
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.
I'm not entirely sure, but check if the
PathResolve
API does the job for you. If not, you could maybe callGetCurrentDirectory
and then append the filename to it.«_Superman_» _I love work. It gives me something to do between weekends.
-
I'm not entirely sure, but check if the
PathResolve
API does the job for you. If not, you could maybe callGetCurrentDirectory
and then append the filename to it.«_Superman_» _I love work. It gives me something to do between weekends.
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. :)