代码之家  ›  专栏  ›  技术社区  ›  Julian de Wit

当请求来自计划程序时,无法写入应用程序数据

  •  0
  • Julian de Wit  · 技术社区  · 15 年前

    您好,我在ASP.NET(网站)项目中有一个页面,它将文件写入app_data文件夹。
    当我从浏览器请求页面时,一切正常。
    当我从提供程序的cron作业调度作业执行此请求时,会收到以下错误

    Could not find a part of the path 'C:\xxxxxxxxxxxxxxx\App_Data\Art_P00004.txt'.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at System.IO.StreamWriter.CreateFile(String path, Boolean append)
       at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
       at System.IO.StreamWriter..ctor(String path, Boolean append)
       at System.IO.File.CreateText(String path)
       at AanbiedingProcessor.DoWriteFiles()
       at TskSendAanbiedingen.DoWork()
    

    有人能帮我吗?

    cron jon作为ASP.NET网站运行在另一个主机/域上。我假设它只是发出一个Web请求。

    2 回复  |  直到 15 年前
        1
  •  0
  •   Richard    15 年前

    这可能是权限问题。

    确保与计划作业关联的用户帐户可以访问app_data文件夹。

    流程监视器可以帮助您准确检查失败的内容和原因。

        2
  •  0
  •   Julian de Wit    15 年前

    问题是路径不存在。:(
    从调度程序调用的脚本与在浏览器中调用的脚本(位置)不同。 请原谅我的困惑。