Process.Start() not starting

  • Thread starter Thread starter xzzy
  • Start date Start date
X

xzzy

In the follwoing code, myProcess.StartInfo.FileName is set to a valid path:
c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word document
in a normal window.


//code++++++++++++++++++++++++++++++++
Process myProcess = new Process();

try
{
LinkButton btnClicked = (LinkButton)sender;
int myID = 1;
myClass.GetByID(myID);
myProcess.StartInfo.FileName = myClass.myDirectory + myClass.myFileName;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Normal;
myProcess.StartInfo.CreateNoWindow = false;
myProcess.Start();
}

catch (Exception ex)
{

//end code++++++++++++++++++++++++++++++++

Thank you,

John
 
Take a close look at what "myClass.myDirectory + myClass.myFileName;" returns.

I bet you're not getting a valid filename or directory path out of it.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
asp.net because its a service and does not have access to the desktop,
can not start a window app only a command line.

if you want to start word (which is not recommanded), you need to use
the automation api.

-- bruce (sqlwork.com)
 
In the follwoing code, myProcess.StartInfo.FileName is set to a valid
path: c:\\hello.doc

The code produces the following error message: "%1 is not a valid Win32
application"

For c:\\hello.doc, I would expect the following code to open a Word
document in a normal window.

But how could it possibly do that...?

ASP.NET runs on the server, not on the client...

ASP.NET (principally) receives HttpRequests from web browsers and responds
by streaming HTML back down to the web browser...

Your code will do the following:

1) create a new Process object on the webserver

2) look for the installed application which corresponds to the supplied
filename's extension - in this case, .doc

3) try to instantiate that application and run it in the Process object - on
the server, not on the client.

ASP.NET can't open browser windows - it needs to create client-side markup
(hyperlinks or JavaScript) to do that...
 
the value of

myClass.myDirectory + myClass.myFileName

is

c:\\hello.doc

which is a file located on the server upon which asp.net is being served
from ( in other words, it's not on the client )
 
asp.net because its a service and does not have access to the desktop,
can not start a window app only a command line.

Actually you can -- only it won't be visible. Give it a shot. Try and start
notepad then check in task manager
 
Back
Top