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