c# - 值不能为空。参数名称: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
?
解决方案
推荐阅读
- java - Spring MVC @PathVariable 列表输入 javax 最大大小验证
- r - 当我将数据从 excel 导入 rstudio 时,它会消除数字中的小数点
- html - 在包含多个实例的 TTF 文件中为 @font-face 使用特定实例
- python - Django/Python“django.core.exceptions.ImproperlyConfigured:无法导入‘联系人’。检查‘...apps.contact.apps.ContactConfig.name’是否正确”
- python - 如何在同一个列表中有两个 for 循环,但第二个从第一个循环的下一个值开始?
- python - 使用 joblib 腌制文件时出现 TypeError
- google-chrome - 所有服务人员都无法注册“TypeError:获取脚本时发生未知错误”。– 但仅在 Chrome 上
- javascript - Javascript:表单提交事件未触发
- python - pyInstaller 和 Django:无法导入 Django
- java - 递归代码不重复三角形绘图