1

I have created a minimalistic pdf viewer using SumatraPDF as an EXE within a my main form.

Everything works fine when I'm debugging it. For the debug test argument, I have a path with spaces, "C:\Path With Spaces\test.pdf", that my program opens fine using SumatraPDF.

To test how it works on my machine, I use the EXE in the Debug folder and make it the default program to open PDFs. When I attempt to open the test pdf file, my program attempts to open these paths and fails:

  • "C:\Path"
  • "C:\Path With Spaces\With"
  • "C:\Path With Spaces\Spaces\test.pdf"

Which leads me to believe that my program is not behaving like other installed programs and treating a filename (with spaces) it is about to open, as one single argument. For example I can set SumatraPDF as the default program and there is no problems opening a filename with spaces.

So my question is (was) does an installed program read arguments differently than an EXE from the debug version?

Shog9
  • 156,901
  • 35
  • 231
  • 235
  • What are the contents of the string[] array when that test pdf is opened? Is it what you'd expect ([1] = c:\path, [2] = with, [3] = Spaces\text.pdf )? Or is it something else? – Tim Jul 22 '14 at 19:49
  • Yes, all the contents are as expected. When I'm debugging everything works perfectly with spaces, but when use the exe by itself (not debugging) then it seems to give my exe multiple arguments when there are spaces. – user2056006 Jul 22 '14 at 19:56
  • Why was this marked as a duplicate of that question? It's actually the exact opposite of the question. The question is about the arguments coming IN, not trying to send the arguments OUT. – Tim Jul 22 '14 at 20:00
  • Yeah, this is different, although I did solve my problem. I can't just use the EXE and expect the proper results, I had to actually install it. :/ – user2056006 Jul 22 '14 at 20:16
  • 1
    It's the same issue: how to quote strings correctly. The second answer, especially, contains very good information about how the command interpreter treats quotes. – Jim Mischel Jul 22 '14 at 20:20
  • Maybe it's the way I worded the question, but if you read over again you can see that I have figured out how to quote strings. the problem is that I get a different situation when I'm not debugging. – user2056006 Jul 22 '14 at 20:24

0 Answers0