//****上传文件代码
public static bool UpLoadFile(ref HtmlInputFile HtmlFile, string UpFileServicesPath)
{
if (HtmlFile.PostedFile.FileName == "") return false;
//***获取上文件路么
string FilePath = HtmlFile.PostedFile.FileName;
//****获取文件名
string FileName;
//***获取扩展名
string FileExiteName = "";
//****创建一个新的文件名
string NewFileName = DateTime.Now.Year.ToString() + FormatDate(DateTime.Now.Month.ToString()) + FormatDate(DateTime.Now.Day.ToString()) + FormatDate(DateTime.Now.Second.ToString());
FileName = FilePath.Substring(FilePath.LastIndexOf("//") + 1);
FileExiteName = FilePath.Substring(FilePath.LastIndexOf("."));
//****组成新的文件名
string CreateNewFileName = NewFileName + FileExiteName;
try
{
//****上传文件到服务器上
HtmlFile.PostedFile.SaveAs(UpFileServicesPath + "//" + CreateNewFileName);
//****上传文件成功,则返回True,否返回false;
return true;
}
catch
{
return false;
}
}
//****将下面的代码添加到web.config中
<httpRuntime executionTimeout="100" maxRequestLength="409600" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/>