473,394 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

opening mspaint

Tam
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?
Nov 15 '05 #1
3 6133
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.

"Tam" <jo***********@btclick.com> wrote in message
news:bm**********@titan.btinternet.com...
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?

Nov 15 '05 #2
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
Nov 15 '05 #3
Tam
Ok, sure, should have got that one. DOH

Thanks fellas, workred a treat ;-)

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:Ot****************@TK2MSFTNGP09.phx.gbl...
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.

"Tam" <jo***********@btclick.com> wrote in message
news:bm**********@titan.btinternet.com...
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?


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open,...
3
by: Greg | last post by:
On my report I want to have an opening balance signifying all transactions up to the month selected and detailed transactions for the month selected and then a closing blance. I'm perpelexed...
8
by: Vigneshwaran G via DotNetMonster.com | last post by:
Hi , I am in need of opening a new IE browser with an URL from my windows form, coded in vb.net. I tried with the following code. Dim psi As New ProcessStartInfo psi.FileName = "iexplore"...
1
by: Tim Marshall | last post by:
In my not too successful attempts to get an OLE chart object (Graph 11.0) that has been manipulated on a form to be reproduced on a report, I am considering the following procedure. First copy the...
0
by: Matt | last post by:
Good afternoon all, I have a VB.NET 2005 application that I'm looking to add some functionality to. The basic idea is to have a place where the user can create a little sketch and save it. ...
2
by: Krish | last post by:
I have an application that I want to open from my .net application. I want this application as a clild window of my application. not as a separate process. Is this posssible? ...
4
by: Crisis | last post by:
Basically, i have a program that shows images and i want it to open the image currently selected with mspaint so they can edit it. Currently i can open paint when the user clicks a button i have...
3
by: MLH | last post by:
What's the best way to launch MSPAINT c:\image.bmp from a VBA procedure. Seeking the route with the least number of complications. Hopefully there will be no more complications than if I clicked...
8
by: cobolguy | last post by:
I can execute mspaint using VBA but I have not been successful trying to open a .jpg image file. This command works to execute mspaint but I do not know how to excute and bring up a file at the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.