获取文件的相关知识,获取文件相关知识
分享于 点击 15941 次 点评:144
获取文件的相关知识,获取文件相关知识
string FilePath = FileUpload1.PostedFile.FileName;//获取上传文件的路径
string FileName = FilePath.Substring(FilePath.LastIndexOf("\\")+1);//获取文件名称
string FileSize = Convert.Tostring(FileUpload1.PostedFile.ContentLength);//获取文件大小
string FileExtend = FilePath.Substring(FilePath.LastIndexOf(".")+1);//获取文件扩展名
string FileType = FileUpload1.PostedFile.ContentType;//获取文件类型
string ServerPath = Server.MapPath("指定文件夹名称")+FileName;//保存到服务器的路径
FileUpload1.PostedFile.SaveAs(ServerPath);//确定上传文件
说明:上文中FileUpload1为使用的FileUplaod文件上传控件
相关文章
- 暂无相关文章
用户点评