这个之前开发的一个网站,管理员进入以后有向服务器上传文件的权限.让各个客户端定时更新广告,以便实现终端机远程广告下载并自动更新).找了段代码,让大家参考一下 // ****上传文件代码 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 " />