Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CF 3.5 System.Diagnostics.ProcessStartInfo - File Not Found

Posted on 2008-10-15
4
1,279 Views
Last Modified: 2013-11-17
Hi..
I'm using the compact framework and trying to lauch a program with the following code.
But I get file not found. The file is int he Program FIles folder
what am I doing wrong ? thanks

     System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
                Info.FileName = TEST.EXE;
                Info.UseShellExecute = false;
                Info.Arguments = null;
                Info.WorkingDirectory = "\program files\myCrap\:
                System.Diagnostics.Process.Start(Info);
0
Comment
Question by:JElster
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:jfmador
ID: 22723482
Use double \ for your path, because "\" will look for a special character like \n for new line \t for a tab space, etc.  You can also use @ before your string to prevent the compiler to translate the \ as a special charater

this :
Info.WorkingDirectory = "\\program files\\myCrap\\":
or
Info.WorkingDirectory = @"\program files\myCrap\":

instead of this
Info.WorkingDirectory = "\program files\myCrap\:
0
 
LVL 1

Author Comment

by:JElster
ID: 22723983
Hi..
I tried those.. same issue
????
0
 
LVL 5

Accepted Solution

by:
jfmador earned 100 total points
ID: 22724054
try using full path in filename instead of workingdirectory
Also add a System.IO.FileExists Condition and show the full path if file not found, be sure you didn't mistyped the file name

     System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
                Info.FileName = @"\program files\mycrap\TEST.EXE";
                Info.UseShellExecute = false;
                Info.Arguments = null;

    if (System.IO.File.Exists(info.FileName))
          System.Diagnostics.Process.Start(Info);
    else
         MessageBox.Show("Unable to find : " + info.FileName);
0
 
LVL 1

Author Comment

by:JElster
ID: 22724730
If I set the filename with the path it works
If I set the working directory with just the path it does not.

???
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question