473,799 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

opening mspaint

Tam
Having problems with this code.

ProcessStartInf o info = new ProcessStartInf o();
info.FileName = ("mspaint.exe") ;
info.Arguments = image.getFileNa me; // returns full path and name
info.ShellExecu te = false;
Process p1 = ProcessStart(in fo);

Problem arises on complicated pathnames. If the string returned in
info.Arguments is in say c:\pics\pic1.bm p 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.bm p (regardless of contents of
getFileName();

Whats happening?
Nov 15 '05 #1
3 6166
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.btinte rnet.com...
Having problems with this code.

ProcessStartInf o info = new ProcessStartInf o();
info.FileName = ("mspaint.exe") ;
info.Arguments = image.getFileNa me; // returns full path and name
info.ShellExecu te = false;
Process p1 = ProcessStart(in fo);

Problem arises on complicated pathnames. If the string returned in
info.Arguments is in say c:\pics\pic1.bm p 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.bm p (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\Deskto p\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:\Documen ts and Settings\Deskto p\MyAss.bmp"

So, in your code you would have:

info.Arguments = "\"" + image.getFileNa me + "\"";

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.r illing.net> wrote in message
news:Ot******** ********@TK2MSF TNGP09.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.btinte rnet.com...
Having problems with this code.

ProcessStartInf o info = new ProcessStartInf o();
info.FileName = ("mspaint.exe") ;
info.Arguments = image.getFileNa me; // returns full path and name
info.ShellExecu te = false;
Process p1 = ProcessStart(in fo);

Problem arises on complicated pathnames. If the string returned in
info.Arguments is in say c:\pics\pic1.bm p 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.bm p (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
714
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, FileAccess.ReadWrite, FileShare.None); which does not prevent me from opening the file even if another user has the file open ie Notepad, it will prevent me from saving the file in notepad until i close the file in the app. I can then save changes made in...
3
10607
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 how to do this Anyone knows how the banks do it with statement formatting? suggestions, ideas welcome.
8
2813
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" psi.Arguments = "http://www.google.com" Process.Start(psi) it worked initially. But now I recieve the error
1
9049
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 graph area to the clip board (easy enough using Me.OleGraphControl.ChartArea.Copy). Next open an instance of MS Paint, paste the clipboard into the file and save as something like "Picture.bmp" in the same directory as the FE Access app. A...
0
1163
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. When the user saves it I need to (behind the scenes) save the picture file and the location of the picture file. I'm going to put the location of the picture in a database for the user to call up later.
2
1084
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? System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "Mspaint.exe"; p.Start(); The following code will open mspaint from my application.. but it will be a free window. I want this to be like a child window of my
4
9100
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 set out however i cannot get paint to open the file being viewed. I get the error "File path not found" but i'm not sure why, i thought it would be as simple as adding the "filepath" variable onto it. Here's the code i currently have:...
3
2429
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 START and typed in the command myself.
8
19515
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 time. I am using Access 2007. Dim retVal retVal = Shell("c:\windows\system32\mspaint.exe", vbMaximizedFocus)
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.