C# ASP.NET 遇到的坑

c# 文件上传"不支持给定路径的格式"

HttpPostedFile file = HttpContext.Current.Request.Files["file"];//接收
string fileName = Path.GetExtension(file.FileName);
string path = ConfigurationManager.AppSettings["ImgsFileDir"] + LINKGUID + "\\";
if (!Directory.Exists(path))
{
   Directory.CreateDirectory(path);
}
using (var fs = new FileStream(Path.Combine(path, fileName), FileMode.Create))
{
     var buffer = new byte[file.InputStream.Length];
     file.InputStream.Read(buffer, 0, buffer.Length);
     fs.Write(buffer, 0, buffer.Length);

}

 

出错日志:

  在 System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
  在 System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)

我认为是 路径错误(我是白菜,如果有高手知道可做解答)

我改成了 G:\FILE\  就好了.......

 

错误:  未能加载文件或程序集-“Microsoft.AI.Web”或它的某一个依赖项

IIS 配置的虚拟路径下有一个web.config

确保web.config 中没有其他过多的引用签

<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>

 

 

参考链接:http://www.cftea.com/c/2017/05/7976.asp

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值