我的目的就是点击一个Button,弹出一个类似FileBrowserDialog的对话框,选中文件夹就可以把路径显示在一个TextBox里边,请教!

解决方案 »

  1.   


    <input id="Text1" type="text" />
    <input id="File1" type="file" onchange="Text1.value=File1.value"/>
      

  2.   

    好象是Server.MapPath(...)  
      

  3.   

    FileUpload控件  不过是选择文件的。
      

  4.   

    用FileUpLoad的话,获取的是文件路径,我需要的是一个只能获取文件夹路径的窗体方法。用FileUpLoad你怎么知道我当前选中的是文件夹还是还是文件?
      

  5.   

    FolderBrowserDialog是返回文件夹路径,在ASP.NET中如何写呢?
      

  6.   


    Server.MapPath()  
      

  7.   


    你那先要给个string,然后获得的是该文件对应的物理地址。我想要的效果是类似FileUpLoad控件一样弹出一个窗体,然后选择文件夹。
      

  8.   

    那样做不到哦,我只好曲向救国啊。
     TableLogOnInfo myLogInfo = new TableLogOnInfo();
            string strPath = Server.MapPath("CrystalReport.rpt");
            ReportDocument myReport = new ReportDocument();        myReport.Load(strPath);
            this.CrystalReportViewer1.ReportSource = myReport;        myLogInfo.ConnectionInfo.ServerName = "(local)";
            myLogInfo.ConnectionInfo.DatabaseName = "Persons";
            myLogInfo.ConnectionInfo.UserID = "sa";
            myLogInfo.ConnectionInfo.Password = "123456";
            myReport.Database.Tables[0].ApplyLogOnInfo(myLogInfo);        ExportOptions exportOpts = new ExportOptions();
            DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
            exportOpts = myReport.ExportOptions;
            exportOpts.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
            string foderPath = "C:\\Temp\\CrystalReport";
            if(!System.IO.Directory.Exists(foderPath))
            {
                System.IO.Directory.CreateDirectory(foderPath);
            }        Response.Clear();
            //   设置导出格式。   
            switch (DropDownList1.SelectedItem.Text)
            {
                case "PDF":                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
                    diskOpts.DiskFileName = foderPath+"\\CrystalReport.pdf";
                    Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.pdf");
                    Response.ContentType = "application/ms-pdf";
                    break;
                case "WORD":
                    exportOpts.ExportFormatType = ExportFormatType.WordForWindows;
                    diskOpts.DiskFileName = foderPath+"\\CrystalReport.doc";
                    Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.doc");
                    Response.ContentType = "application/ms-word";
                    break;
                case "EXCEL":
                    exportOpts.ExportFormatType = ExportFormatType.Excel;
                    diskOpts.DiskFileName = foderPath+"\\CrystalReport.xls";
                    Response.AppendHeader("Content-Disposition", "attachment;filename=CrystalReport.xls");
                    Response.ContentType = "application/ms-excel";
                    break;
                default:
                    break;        }        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            exportOpts.DestinationOptions = diskOpts;
            myReport.Export();
            myReport = null;
            myLogInfo = null;        /******************************************************************************/
            //获取的是网站根目录对应的物理地址
            //string path = Server.MapPath("~");
           
            Response.Buffer = true;
            Response.Charset = "GB2312";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
             
            this.EnableViewState = false;
            Response.WriteFile(diskOpts.DiskFileName);
            代码是把一个水晶报表导出,可以导出为PDF,EXCEL,DOC三种格式,想要多的格式,自己可以再加。