值不能为空参数名称: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 (将#修改为@)