C#winform用webclient的 uploadfile方法上传文件,多个客服端同时上传文件,怎样处理并发问题,怎样排队
服务器端代码/服务器默认保存路径privatereadonlystringserverPath=@"C:\upload\";protectedvoidPage_Load(...
服务器端代码
/服务器默认保存路径
private readonly string serverPath = @"C:\upload\";
protected void Page_Load(object sender, EventArgs e)
{
// 获取 http提交上传的文件, 并改名保存
foreach (string key in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[key];
//string newFilename = DateTime.Now.ToString("yyMMddhhmmssffff")
// + file.FileName.Substring(file.FileName.LastIndexOf('.'));
string newFilename = file.FileName;
try
{ //文件保存并返回相对路径地址
file.SaveAs(this.serverPath + newFilename);
Response.Write("upload/" + newFilename);
}
catch (Exception)
{
}
}
} 展开
/服务器默认保存路径
private readonly string serverPath = @"C:\upload\";
protected void Page_Load(object sender, EventArgs e)
{
// 获取 http提交上传的文件, 并改名保存
foreach (string key in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[key];
//string newFilename = DateTime.Now.ToString("yyMMddhhmmssffff")
// + file.FileName.Substring(file.FileName.LastIndexOf('.'));
string newFilename = file.FileName;
try
{ //文件保存并返回相对路径地址
file.SaveAs(this.serverPath + newFilename);
Response.Write("upload/" + newFilename);
}
catch (Exception)
{
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询