running a external program on server side

W

wakun

Hi there,
I have my webpage written in C# and I am going to run an external
program within the web page. I have my code like

using System;
using System.Diagnostics;

namespace NRP
{
public class RP:System.Web.UI.Page
{
public void tryit()
{
ProcessStartInfo Info = new ProcessStartInfo();

Info.FileName = "A.exe"; // here A.exe will create a new file
on server side
Info.WorkingDirectory = "D:\\temp";
Process Proc ;

try
{
Proc = Process.Start(Info);
}
catch(System.ComponentModel.Win32Exception eee)
{
// error here
return;
}
}
}

I test the code on the local IIS and it works. However, when I put the
code and the DLL on the webserver, it didn't work. I guess it is becase
I didn't set the path of the program properly, but I have no idea how
to set WorkingDirectory properly on server side while I didn't know the
exact path.
 
E

Eliyahu Goldin

Create a folder in your virtual directory and use it as a working directory.
You can get the physical path with the MapPath method.

Note that it is likely that the problem is not in missing path. You may be
encountering a security problem of the asp.net account not having enough
rights for accessing and running the external application.

Eliyahu
 
W

wakun

Thanks. It works! I try two cases

1) I written a little program in C to create a text file on the server
side. Everything is all right!
2) I try to run another program on server side, it is veeeery slow and
output nothing, no error was outputted. !?
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top