opening mspaint

  • Thread starter Thread starter Juan Gabriel Del Cid
  • Start date Start date
J

Juan Gabriel Del Cid

Remember that spaces are delimiters. So, if you run:

mspaint.exe C:\Documents and Settings\Desktop\MyAss.bmp

you are sending 3 arguments to mspaint.exe (separated by spaces). What you
want to do is group them into one argument with double quotes:

mspaint.exe "C:\Documents and Settings\Desktop\MyAss.bmp"

So, in your code you would have:

info.Arguments = "\"" + image.getFileName + "\"";

That should work,
-JG
 
Having problems with this code.

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = ("mspaint.exe");
info.Arguments = image.getFileName; // returns full path and name
info.ShellExecute = false;
Process p1 = ProcessStart(info);

Problem arises on complicated pathnames. If the string returned in
info.Arguments is in say c:\pics\pic1.bmp then it loads fine. Only when
cming from say the desktop is there a problem, it doesnt load the file and
informs me it cant find c:\Documents.bmp (regardless of contents of
getFileName();

Whats happening?
 
Spaces can throw any path out-of-whack. Try wrapping the path to the
document in quotation marks before launching the process. The shell thinks
the path ends after the first space. Although a nuisance, it does make
sense when you think about it. Applications can accept any number of
parameters and if spaces are used to separate them, it is difficult for the
system to know what is a delimiter and what is a valid character within the
parameter.
 
Back
Top