您的位置:首页 > 其它

获取url文件名和扩展名及服务器路径的方法

2016-05-11 13:57 369 查看
获取文件名:用字符串的Substring方法:

string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);


获取文件扩展名:用Path.GetExtension(url)方法:

string fileType = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);


获取服务器路径:Server.MapPath(相对路径)方法:

serverpath = Server.MapPath("../files/UploadFile/") + filename;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: