微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

值不能为空参数名称:path1

如何解决值不能为空参数名称:path1

我正在尝试使用以下设置下载文件。问题是,我收到一个异常说

Value cannot be null. Parameter name: path1

出于某种原因,DownloadLocationT 为空,我不知道为什么。

if (dl.EndsWith(".las"))
    {
        dl = dl.Replace("{","").Replace("}","").TrimEnd("las".tochararray()) + "zip";
    }
    FileInfo fi = new FileInfo(dl);
    var newFile = Path.Combine(Startup.appSettings.DownloadLocationT,fi.Name);
        if (System.IO.File.Exists(newFile))
            {
                System.IO.File.Delete(newFile);
                Thread.Sleep(2000);
            }
         System.IO.File.copy(dl,newFile);
         return Ok(dl);

这是appSettings

public class AppSettings
    {
        public string ArecGISConnString { get; set; }
        public string AllowOrigin { get; set; }
        public string DMSUrl { get; set; }
        public string DownloadLocation { get; set; }
        public string DownloadLocationT { get; set; }
        public string AdminemailToVerify { get; set; }
        public string PoTreePath { get; set; }
        public string PoTreeOut { get; set; }
        public string MetadataPath { get; set; }
        public string Referer { get; set; }
    }

和实际的 appSettings

"AppSettings": {
   //shortened for brevity
    "DownloadLocationT": "C:\\Downloads","AdminemailToVerify": "info@info.com"
  }

我收到一条异常消息 Value cannot be null. Parameter name: path1 似乎找不到 DownloadLocationT 的路径或文件夹?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。