bluexq - 2013/7/23 15:55:20
新建了一个产品帮助手册模型 ,怎么获取附件的大小及扩展名。 因为需要在前台显示附件大小及扩展名。
xiyou - 2013/7/24 10:43:15
- <script runat="server" language="c#">
- private string filesize(string files) //获取文件大小
- {
- strin Rn = "";
- if (!string.IsNullOrEmpty(files))
- {
- if (System.IO.File.Exists(Server.MapPath(files)))
- {
- System.IO.FileInfo FI = new System.IO.FileInfo(Server.MapPath(files));
- Rn= FI.Length.ToString() ;
- }
- }
- return Rn;
- }
- private string fileext(string files) //获取文件扩展名
- {
- strin Rn = "";
- if (!string.IsNullOrEmpty(files))
- {
- if (System.IO.File.Exists(Server.MapPath(files)))
- {
- System.IO.FileInfo FI = new System.IO.FileInfo(Server.MapPath(files));
- Rn= FI.Extension;
- }
- }
- return Rn;
- }
- </script>
复制代码把这个方法放在模型顶部,模型中直接调用.
bluexq - 2013/7/24 13:02:30
放在模型顶部,出错呀!
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
bluexq - 2013/7/25 19:06:34
程序出错呀。! 有人能解答一下吗?
bluexq - 2013/7/27 18:08:49
[code]<script runat="server" language="c#"> private string filesize(string files) //获取文件大小 { strin Rn = ""; if (!string.IsNullOrEmpty(...... xiyou 发表于 2013-7-24 10:43:15  |
终于搞定了,原来是是声明字符串变量少个字母 g,