为何不能像导出Excel,Word等方式导出一个文件夹?

解决方案 »

  1.   

    Dir.Exists(path)你判断存不存在文件夹 不存在直接Dir.Create(path)
      

  2.   

    if (Directory.Exists(path))
                            {                            FileInfo file = new FileInfo(path);
                               
                                Response.Clear();
                                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); 
                                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
                                Response.AddHeader("Content-Length", file.Length.ToString());
                                Response.ContentType = "application/octet-stream";
                                Response.WriteFile(file.FullName);
                                Response.End();
                            }                        else
                            {                            Page.RegisterStartupScript("", "<script>alert('文件夹不存在!')</script>");
                            }
    我用这个方式不能导出文件夹,但是奇怪,这个路径下的这个文件夹确实是存在的,请高手帮忙解决这个问题
      

  3.   

    额,文件夹只是个“虚拟概念”他并不存在一个具体的实际文件,那么你输出一个二进制流有啥意义?ps:如果你想这么做,请使用ftp,而不是http