Alex Rivera | Logout

Relative path to a file using C#

Asked 2011-01-19T20:49:06.127
10

I have a command-line program that takes a configuration file as a parameter, that is, C:\myprogram.exe -c C:\configFiles\MyConfigFile.txt. I want to be able to make it so that I do not have to type the absolute path to the configuration file, so instead of the above I can just enter C:\myprogram.exe -c MyConfigFile.txt

I'm not familiar enough with how C# deals with paths to understand if or how this can be done. Any insight is appreciated.

Edit
Report

1 Answer

0

Without the relative path as part of the input argument, your application would need to:

  • either search for the file that is passed in
  • append the path name of the Config directory to the filename
answered 2011-01-19T20:54:10.503

Your Answer