Solved

CF 3.5 System.Diagnostics.ProcessStartInfo - File Not Found

Posted on 2008-10-15
4
1,274 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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.   …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now