private void upFile() //该方法用于执行文件上传操作
{ string strFileName; //获取文件夹路径 string FilePath = Server.MapPath("./") + "File"; // 判断是否存在上传文件 if (FileUpload1.PostedFile.FileName != null) { strFileName = FileUpload1.PostedFile.FileName; //保存上传文件的整个信息 strFileName = strFileName.Substring(strFileName.LastIndexOf("\\") + 1); //过滤盘符,获取文件名,或者直 接strFileName =this.FileUpload1.FileName try { FileUpload1.SaveAs(FilePath + "\\" + strFileName ); //以规定的格式保存文件到路径 Label1.Text = "上传文件成功!"; } catch { Label1.Text = "上传失败!"; }
}
} |
|
来自: 寒木萧条 > 《aspDotNet》