编程开发 > ASP > 文章内容

FileUpload上传多文件出现错误的解决方法(一)

2010-10-25编辑:dan

 在使用 public static ArrayList files 变量保存临时上传的文件时,当文件比较大时,会出现“无法访问已关闭的文件”错误,网上也有很多这样的问题,但都没有解决办法。在配置文件中增加

XML/XHTML 代码
<httpRuntime executionTimeout="90" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192"/>

(属性“maxRequestLength”值必须在 0-2097151 范围内。)一行之后,可以解决部分问题,但也不能彻底解决。出现这样的问题的代码是这样写的:

ASPX 代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="admin_Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td align="right">
                    本地文件:
                </td>
                <td>
                    <asp:FileUpload ID="fupFile" runat="server" CssClass="btn" Width="247px" Height="20px"
                        onkeydown="event.returnValue=false;" onpaste="return false" />
                </td>
            </tr>
            <tr>
                <td align="right">
                    文件列表:
                </td>
                <td valign="top">
                    <asp:ListBox ID="lbxFile" runat="server" Height="145px" Width="245px" CssClass="txt">
                    </asp:ListBox>
                </td>
            </tr>
            <tr>
                <td colspan="5">
                    <asp:Button ID="btnAdd" runat="server" Text="添加" OnClick="btnAdd_Click" />&nbsp;&nbsp;
                    <asp:Button ID="btnPost" runat="server" Text="上传" OnClick="btnPost_Click" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
ASP.NET实现类似Excel的数据透视表(四)

热点推荐

登录注册
触屏版电脑版网站地图