0

I have C++ multi project, in visual studio 2012, from which a .exe file is generated and there is a huge config.txt file contains many input arguments. So I run my program by this command in command line of windows: program.exe -c config.txt

Now I want to debug this program but I can't give it the config.txt as an input argument file. I tried the answers of Debugging with command-line parameters in Visual Studio

but it didn't mentioned how to give the whole .txt file to visual studio instead of typing arguments in properties->debugging->command argument

in config.txt I have arguments like this :

-numberOfImage 2 ./Lena.jpg ./Barbara.jpg

-imageDimensions 230 230

-minIntensity 0

-maxIntensity 255

and more many inputs which I want to change them easily in .txt file not typing them in command argument. How can I link config.txt to debugger?

patra
  • 9
  • 4
  • 1
    Did you try adding config.txt to the project command line in the project properties: __Debugging > Command Arguments__ (in VS 2017). Note that the working directory is probably not where you think it is, so use a full absolute path to the file until you can verify what the working directory is when launched for debug. – Richard Critten Jun 09 '17 at 20:28
  • You can also specify the working directory actually, and the place to do that is immediately below the option for command arguments. – Benjamin Lindley Jun 09 '17 at 20:36
  • Yes a full absolute path to the file.First, with extension or without? I will try it again. another question, in Command arguments (in VS 2012) I should type absolute path? – patra Jun 09 '17 at 20:37
  • @BenjaminLindley oh, that would be nice. You mean Working Directory which has "$(ProjectDir)" .May I clean it and paste exact absolute address with extension? – patra Jun 09 '17 at 20:40
  • @patra: You wouldn't put any extension, because it is supposed to refer to a directory, not a file, and directories don't have extensions. But yes, you can place an absolute path there. – Benjamin Lindley Jun 09 '17 at 20:42
  • @BenjaminLindley What about the .txt file itself? by now, I just set directory where .txt file exists. – patra Jun 09 '17 at 20:45
  • @patra: You place your command line arguments exactly as you do on the command line (minus the program name) in the location where Richard specified. You said you were running your program with `program.exe -c config.txt`, so put `-c config.txt` in the space for Command Arguments. – Benjamin Lindley Jun 09 '17 at 20:49
  • @BenjaminLindley , Wow, you made it! it works well. how can I give you score ? :) – patra Jun 09 '17 at 20:55
  • @BenjaminLindley, Based on part's reply, this issue has been resolved, would you please post your comment as the answer? So patra could mark it as the answer, and then it could help other community members who meet the same issue. – Jack Zhai-MSFT Jun 12 '17 at 07:35

1 Answers1

0

You can:

  1. Hardcode the name of the file

  2. use the input stream to give another file name

ΦXocę 웃 Пepeúpa ツ
  • 43,054
  • 16
  • 58
  • 83
  • I should try it. Would you describe more? I have many if commands which were compared to "commandName" . Is there and easier way to give that .txt file itself? – patra Jun 09 '17 at 20:34