Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Code
System.Diagnostics.Process P = new System.Diagnostics.Process();
P.StartInfo.FileName = "D:\\Octave\\bin\\octave.exe";
P.Start();

localhost: ok
webhost: not ok, can't find file

Who can help me?
Gerd Schluckebier
Posted

1) Is that file installed in that location on the web server?
2) If Yes, then ensure that the credentials your web app run under have permission to execute that application as well.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 31-Oct-12 15:22pm    
Most likely, this is the path outside the root path associated with the site -- look at the path itself.
Also, hard-coded paths should never be used.

Please see my answer.
--SA
fjdiewornncalwe 31-Oct-12 15:23pm    
Agreed, but I've seen it done like this with a 3rd party installed application that needed to run on a web server (god only knows why) initiated by the IIS application.
Sergey Alexandrovich Kryukov 31-Oct-12 15:32pm    
"God knows why" is a good part of it. :-)
It does not mean hard-coded paths should ever be used anyway. I'm sure using MapPath I advised is the appropriate solution in such cases as well. Don't you think so?
--SA
In any kind of application, there are no situations where any kind hard-coded paths could be useful. In all cases, the path should be calculated based on some user-supplied or configuration data or system environment, such as executable path, "special folders" associated per user accounts or dedicated for all users, and so on. Think about it: nothing guarantees that your next host system will even have "D:" drive. One of my desktop systems does not even have "C:". Using such kind of wanna-be-world-constants is a bad idea in general.

As to the Web applications, they are are more limiting: the application process is executed in a sandboxed environment, so your application won't have access to the file system objects local application may have. And this is a good safety feature. You can only use the part of the file system under the root directory associated with your Web site.

Normally, when a path name in your file system is required for your functionality, you should resolve URIs into local file system path on your server host and use this path. This is done using System.Web.HttpServerUtility.MapPath:
http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900