【问题标题】:Why I can't create a file on the Webserver with a ASP.NET Application?为什么我不能使用 ASP.NET 应用程序在 Web 服务器上创建文件?
【发布时间】:2014-06-17 08:46:28
【问题描述】:

.NET 应用程序,我想执行一个 exe。

到这个exe:

这个 exe 文件是一个显示许可用户的程序。

我在我的开发虚拟机上使用 Visual Studio 2010 对其进行了测试,它可以工作,但如果我将它部署在我的网络服务器上的 iis7 上,它就无法工作。错误是:

错误:无法创建 qrun.inf 文件

有什么问题?为什么应用不能创建文件?

这是我的代码:

Web.Config:

...
<setting name="LSDYNA_CMD" serializeAs="String">
        <value>~\\exe\\lstc_qrun.exe -s lwserv-lic -R</value>
      </setting>
...

exe在我的exe文件夹中

我在这里得到值:

string cmd = Properties.Settings.Default.LSDYNA_CMD;
cmd = Server.MapPath(cmd);

string output = ExecuteCommand(cmd);
...

这里是ExecuteCommand(..) 方法

public static string ExecuteCommand(string command)
{
    int exitCode;
    ProcessStartInfo processInfo;
    Process process;

    try
    {
        processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
        processInfo.CreateNoWindow = true;
        processInfo.UseShellExecute = false;
        processInfo.RedirectStandardError = true;
        processInfo.RedirectStandardOutput = true;

        using (process = Process.Start(processInfo))
        {
            string output = process.StandardOutput.ReadToEnd();
            exitCode = process.ExitCode;

            return output;
        }
   }
   catch (Exception ex)
   {
       return "error: " + ex.Message;
   }
}

我直接在网络服务器上尝试它,我得到了列表 (O.o) 我打开了一个 cmd 并在其中创建了命令。

我需要帮助我不知道该怎么做:(

【问题讨论】:

  • 只有我看到这个会紧张吗?
  • 应该是权限/权限问题。你试过以管理员身份运行吗?
  • 创建qrun.inf文件的路径是什么?
  • 路径是exe文件所在的位置。 ...文件夹 exe --> C:\inetpub\wwwroot\licreader\exe
  • 我可以使用临时文件夹来创建文件吗?

标签: c# asp.net file process exe


【解决方案1】:

在您的文件夹上设置写入许可,如下所示:IIS AppPoolIdentity and file system write access permissions

或者

您可以在您的 ASP.NET 项目中创建新文件夹并将您的 exe 文件放在那里。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 2016-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多