我的网站空间上的路径问题 [英] a path problem on my webspace

查看:51
本文介绍了我的网站空间上的路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码
System.Diagnostics.Process P =新的System.Diagnostics.Process();
P.StartInfo.FileName ="D:\\ Octave \\ bin \\ octave.exe";
P.Start();

本地主机:确定
webhost:不好,找不到文件

谁可以帮助我?
Gerd Schluckebier

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

推荐答案

1)该文件是否安装在Web服务器上的该位置? 2)如果是,则确保您的Web应用程序在其下运行的凭据也具有执行该应用程序的权限.
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.


在任何类型的应用程序中,都不会出现任何类型的硬编码路径可能很有用.在所有情况下,都应根据一些用户提供的或配置数据或系统环境来计算路径,例如可执行路径,每个用户帐户关联的或专用于所有用户的特殊文件夹",等等.考虑一下:没有任何东西可以保证您的下一个主机系统甚至具有"D:"驱动器.我的一个桌面系统甚至没有"C:".通常,使用这种想成为世界常量的想法不是一个好主意.

对于Web应用程序,它们的限制更大:在沙盒环境中执行应用程序过程,因此您的应用程序将无权访问本地应用程序可能拥有的文件系统对象.这是一个很好的安全功能.您只能在与网站关联的根目录下使用文件系统的一部分.

通常,当功能需要文件系统中的路径名时,应将URI解析为服务器主机上的本地文件系统路径,并使用此路径.这是使用System.Web.HttpServerUtility.MapPath:
完成的 http://msdn.microsoft.com/en-us/library/system. web.httpserverutility.mappath.aspx [ ^ ].

—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


这篇关于我的网站空间上的路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆