做了个 文件上传 代码如下:
public string UPdateFile()
    {
        if (!string.IsNullOrEmpty(this.KeyValue_FJPath.PostedFile.FileName))
        {
            string fulname = this.KeyValue_FJPath.PostedFile.FileName;
           string filename = fulname.Substring(fulname.LastIndexOf("\\") + 1);
            string type = fulname.Substring(fulname.LastIndexOf(".") + 1);
            if (type != "doc" && type != "docx" && type != "pdf")
            {
                throw new Exception("只允许上传word文件及pdf文件");
            }
            string GuidStr = Guid.NewGuid().ToString() + "-" + filename;
            string FileUpdatePathFull = Server.MapPath(".") + "\\UpLoadFiles\\" + GuidStr;
            this.KeyValue_FJPath.PostedFile.SaveAs(FileUpdatePathFull);
            return GuidStr;
        }
        else
        {
            return "";
        }
文件下载如下:
 string sFileName = Request.Params["filename"].ToString();
            sFileName = sFileName.Substring(sFileName.LastIndexOf(@"/") > 0 ? sFileName.LastIndexOf(@"/") + 1 : 0);
            Response.ContentType = "application/octet-stream";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
            //Response.Charset = "GB2312";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(sFileName));
            string filename = Server.MapPath(".") + Request.Params["filename"].ToString();
            Response.TransmitFile(filename);
web。config 设置如下:
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
请问 为什么 上传 小文件 能传输成功 大文件 没有反应 是不是跟网速有关系,
下载的时候 有人能下载成功 有人不能 下载成功的是两个ie6的 这段代码应该跟ie没关系的吧。
注:本机上传下载都没问题
在线等解答

解决方案 »

  1.   

    /// <summary>
            /// 下载服务器文件至客户端
            /// </summary>
            /// <param name="url">被下载的文件地址,绝对路径</param>
            /// <param name="dir">另存放的目录</param>
            public void DownloadUrlFile(string url, string dir)
            {
                WebClient client = new WebClient();
                string fileName = Path.GetFileName(url);  //被下载的文件名
                string path = dir + fileName;   //另存为的绝对路径+文件名            try
                {
                    if (!System.IO.Directory.Exists(dir))
                    {
                        System.IO.Directory.CreateDirectory(dir);
                    }
                    if (!System.IO.File.Exists(path))
                    {
                        client.DownloadFile(url, path);
                    }
                }
                catch (Exception)
                {
                    // ShowError("文件下载失败!");
                }
            }
    如果不行看这个webclient
    ftpwebrequest
    http://topic.csdn.net/u/20100101/11/31f537a5-e615-4588-aac8-c82acf1241bb.html 
      

  2.   

    ASP.NET 默认上传文件大小为4MB...
    大文件...目前我找到的都是 使用别人提供的控件...或者,操作数据流..分块存储!!!
      

  3.   

    上传文件代码中你可以手动设置文件大小//获取准备上传的文件的大小
            int length = fuConver.PostedFile.ContentLength;
            //当文件小于2000000字节,即2M时:
            if (length < 2000000)
      

  4.   

    这个webclient 要 先定下来 下载位置啊?还有别的方法么 我的哪里的问题啊