Process.Start() not starting

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
 
J

Juan T. Llibre

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.
 
B

bruce barker

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)
 
M

Mark Rae

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...
 
X

xzzy

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 )
 
R

Rad [Visual C# MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top