产品使用及交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

怎么获取附件的大小及扩展名。 [复制链接]

1#

  1. <script runat="server" language="c#">
  2. private string filesize(string files) //获取文件大小
  3.     {
  4.         strin Rn = "";
  5.         if (!string.IsNullOrEmpty(files))
  6.         {
  7.             if (System.IO.File.Exists(Server.MapPath(files)))
  8.             {
  9.                  System.IO.FileInfo FI = new System.IO.FileInfo(Server.MapPath(files));
  10. Rn= FI.Length.ToString() ;
  11.             }
  12.         }
  13.         return Rn;
  14.     }

  15. private string fileext(string files) //获取文件扩展名
  16.     {
  17.         strin Rn = "";
  18.         if (!string.IsNullOrEmpty(files))
  19.         {
  20.             if (System.IO.File.Exists(Server.MapPath(files)))
  21.             {
  22.                   System.IO.FileInfo FI = new System.IO.FileInfo(Server.MapPath(files));
  23.   Rn= FI.Extension;
  24.             }
  25.         }
  26.         return Rn;
  27.     }
  28. </script>
复制代码
把这个方法放在模型顶部,模型中直接调用.
分享 转发
TOP
发新话题 回复该主题