产品使用及交流论坛

注册

 

QQ登录

只需一步,快速开始

发新话题 回复该主题

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

1#
新建了一个产品帮助手册模型 ,怎么获取附件的大小及扩展名。 因为需要在前台显示附件大小及扩展名。
分享 转发
深圳公司注册: http://www.szwhcw.com
TOP
2#

  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
3#

放在模型顶部,出错呀!

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The value of the property 'mode' cannot be parsed. The error is: The enumeration value must be one of the following: RemoteOnly, On, Off.

Source Error:


Line 16:     <compilation defaultLanguage="C#" debug="false" />
Line 17:     <authentication mode="Forms" />
Line 18:     <customErrors mode="on">
Line 19:       <error statusCode="404" redirect="/err404.htm" />
Line 20:     </customErrors>

Source File: D:\wwwroot\web.config    Line: 18
深圳公司注册: http://www.szwhcw.com
TOP
4#

程序出错呀。!  有人能解答一下吗?
深圳公司注册: http://www.szwhcw.com
TOP
5#

[code]<script runat="server" language="c#">
private string filesize(string files) //获取文件大小
    {
        strin Rn = "";
        if (!string.IsNullOrEmpty(......
xiyou 发表于 2013-7-24 10:43:15
终于搞定了,原来是是声明字符串变量少个字母 g,
深圳公司注册: http://www.szwhcw.com
TOP
发新话题 回复该主题