加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – asp.net mvc HttpPostedFileBase获取文件扩展名

发布时间:2020-12-15 19:07:50 所属栏目:asp.Net 来源:网络整理
导读:public string ContructOrganizationNameLogo(HttpPostedFileBase upload,string OrganizationName,int OrganizationID,string LangName) { var UploadedfileName = Path.GetFileName(upload.FileName); string type = upload.ContentType; } 我想得到文件的
public string ContructOrganizationNameLogo(HttpPostedFileBase upload,string OrganizationName,int OrganizationID,string LangName)
    {
         var UploadedfileName = Path.GetFileName(upload.FileName);
        string type = upload.ContentType;
    }

我想得到文件的扩展名动态生成文件的名称。一种方式,我将使用拆分类型。但是我可以使用HttpPostedFileBase对象来获得扩展以干净的方式吗?

解决方法

喜欢这个:
string extension = Path.GetExtension(upload.FileName);

这将包括一个前导..

注意,你不应该假设扩展名是正确的。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读