我要实现的功能;我在点net里上传大文件时,当上传到5M时,我要求有提示,
我现在的问题:我在上传时用if(this.File1.PostedFile.InputStream.Length>1024*1024*5)这个来限制大小,但是在上传大文件时还是会先去读入全部的文件,再检查大小,晕死了,我本来是想不全部读入文件,就可以检查大小.
有没办法不读入全部的文件,就能知道它的大小,用INPUT type="file" id="File1" name="File1" runat=server size="28"来实现的,在点net里有没有办法呢

解决方案 »

  1.   

    这样不用啊,在WEB。CONFIG里添加设置代码:
    <configuration>
    <system.web>
    <httpruntime
     maxrequestlength="4096"//此大小为默认值,此值可以根据需要改变
    executiontimeout="600"//此值指定上传文件有效时间为10分钟
    />
    </system.web>
    </configuration>修改machine.config
    httpRuntime Attributes:
      //修改时间        executionTimeout="[seconds]" - time in seconds before request is automatically timed out
      //修改大小        maxRequestLength="[KBytes]" - KBytes size of maximum request length to accept
              useFullyQualifiedRedirectUrl="[true|false]" - Fully qualifiy the URL for client redirects
              minFreeThreads="[count]" - minimum number of free thread to allow execution of new requests
              minLocalRequestFreeThreads="[count]" - minimum number of free thread to allow execution of new local requests
              appRequestQueueLimit="[count]" - maximum number of requests queued for the application
              enableKernelOutputCache="[true|false]" - enable the http.sys cache on IIS6 and higher - default is true
              enableVersionHeader="[true|false]" - outputs X-AspNet-Version header with each request