请教各位天才: 如何在asp.net(c#)环境下实现浏览文件夹的功能??? 非常感谢您的关照!!!

解决方案 »

  1.   

    去找找有没有现成的控件HtmlFile 不是可以吗
      

  2.   

    不知你说的浏览文件夹是什么意思,可以引用System.IO,然后定义Directory.***就行了.
    如果想要图形化界面的得按需要加载DirectoryDialog或FileDialog控件.试试吧.
      

  3.   

    DirectoryDialog或FileDialog控件 好像在asp.net开发环境下不能用 在winForm窗体下我能实现
    谢谢
      

  4.   

    ASP.NET没有现成的浏览文件夹的控件,只在HTML组件中有个FILE FIELD是浏览文件用的,看来楼主得用Tree写了。
      

  5.   

    如何在asp.net(c#)环境下实现浏览(服务器上的)文件夹的功能?
    怎么没人来帮呢?
    谢谢前几位的指点 可能我没说清楚
      

  6.   

    如何在asp.net(c#)环境下实现浏览(服务器上的)文件夹的功能?各位请教您了
      

  7.   

    如何在asp.net(c#)环境下实现浏览(服务器上的)文件夹的功能?各位请教您了
    还有没有高招了?
      

  8.   

    自己递归检索出所有文件夹然后用TreeView加载!
      

  9.   

    客户端可以使用fso( file sytem object )
      

  10.   

    只能自己写,在WEB里面,还没有现成的控件能实现这样的目标.
    TNND,微软公司也不想个办法搞一个出来.
      

  11.   

    就是!  .net中webForm下就没有winForm开发环境下的功能多!!怎么微软怎么就难为webForm开发人员呢??
      

  12.   

    不是微软难为webForm开发人员,大多数是为安全性考虑
      

  13.   

    这个没有。
    -----------------
    实在不行,自行写个ActiveX吧。
      

  14.   

    桌面应用程序和WEB应用程序天生是有差别的楼主说的浏览服务器端文件夹的方法 是完全可以做到的
    <%@ Page Language="C#" %>
    <%@ import Namespace="System.IO" %>
    <script runat="server">    // Insert page code here
        //
        void Page_Load(object sender,EventArgs e)
        {       if(!IsPostBack)
            {
                string DiskPath = Server.MapPath(".");
                lblRootPath.Text = Server.MapPath(".");
                BindDiskInfo(DiskPath);
            }
        }
        void BindDiskInfo(string DiskPath)
        {
            DirectoryInfo di = new DirectoryInfo(DiskPath);        DataGrid1.DataSource = di.GetDirectories();
            DataGrid1.DataBind();        DataGrid2.DataSource = di.GetFiles();
            DataGrid2.DataBind();        ViewState["ParentPath"] = di.Parent.FullName;
            ViewState["CurrentPath"] = DiskPath;
            //ViewState["ParentPath"] = Server.MapPath("..");    }    void Button1_Click(object sender, EventArgs e) {
            DirectoryInfo di = new DirectoryInfo(ViewState["CurrentPath"].ToString());
            string SubDirName = tbxDirectoryName.Text.Trim();
            di.CreateSubdirectory(SubDirName);        DataGrid1.DataSource = di.GetDirectories();
            DataGrid1.DataBind();
        }    void DataGrid1_SelectedIndexChanged(object sender, EventArgs e) {    }    void DataGrid1_EditCommand(object sender, DataGridCommandEventArgs e) {
            string DiskPath = e.Item.Cells[0].Text.Trim();
            BindDiskInfo(DiskPath);
        }    void Button2_Click(object sender, EventArgs e) {
            if(lblRootPath.Text.Length > ViewState["ParentPath"].ToString().Length)
            {
                return;
            }
            BindDiskInfo(ViewState["ParentPath"].ToString());
        }    void Button3_Click(object sender, EventArgs e) {
            string ClientFileName = upFile.Value;
            string[] TempArr =  ClientFileName.Split("\\".ToCharArray());
            string ClientFileExtendName = TempArr[TempArr.Length - 1];        string SaveFileName = ClientFileExtendName;
            upFile.PostedFile.SaveAs(Server.MapPath(SaveFileName));        BindDiskInfo(ViewState["CurrentPath"].ToString());
        }</script>
    <html>
    <head>
    </head>
    <body>
        <form runat="server">
            <!-- Insert content here --><asp:Label id="lblRootPath" runat="server" forecolor="#cceeaa" font-size="Larger" backcolor="Blue"></asp:Label>
            <table style="BORDER-RIGHT: blue 1px solid; BORDER-TOP: blue 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: blue 1px solid; BORDER-BOTTOM: blue 1px solid" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tbody>
                    <tr>
                        <td width="320">
                            <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged" OnEditCommand="DataGrid1_EditCommand">
                                <Columns>
                                    <asp:BoundColumn DataField="FullName" HeaderText="文件夹"></asp:BoundColumn>
                                    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="进入"></asp:EditCommandColumn>
                                </Columns>
                            </asp:DataGrid>
                            <br />
                            <div style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid">
                                <asp:TextBox id="tbxDirectoryName" runat="server"></asp:TextBox>
                                <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="NewDir"></asp:Button>
                                <asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="ToParent"></asp:Button>
                                <br />
                                <input id="upFile" type="file" runat="server" />
                                <asp:Button id="Button3" onclick="Button3_Click" runat="server" Text="Save"></asp:Button>
                            </div>
                        </td>
                        <td width="2" bgcolor="#aaccee">
                            &nbsp;
                        </td>
                        <td>
                            <asp:DataGrid id="DataGrid2" runat="server" AutoGenerateColumns="False">
                                <Columns>
                                    <asp:BoundColumn DataField="Name" HeaderText="文件名"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="Length" HeaderText="大小"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="LastWriteTime" HeaderText="最后更新时间"></asp:BoundColumn>
                                     <asp:TemplateColumn>
                                        
                                        <ItemTemplate>
                                            <a target="_blank" href='<%#DataBinder.Eval(Container.DataItem,"Name")%>'>浏览</a> 
                                        </ItemTemplate>
                                    </asp:TemplateColumn>
                                </Columns>
                            </asp:DataGrid>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </body>
    </html>
      

  15.   

    桌面应用程序和WEB应用程序天生是有差别的楼主说的浏览服务器端文件夹的方法 是完全可以做到的
    <%@ Page Language="C#" %>
    <%@ import Namespace="System.IO" %>
    <script runat="server">    // Insert page code here
        //
        void Page_Load(object sender,EventArgs e)
        {       if(!IsPostBack)
            {
                string DiskPath = Server.MapPath(".");
                lblRootPath.Text = Server.MapPath(".");
                BindDiskInfo(DiskPath);
            }
        }
        void BindDiskInfo(string DiskPath)
        {
            DirectoryInfo di = new DirectoryInfo(DiskPath);        DataGrid1.DataSource = di.GetDirectories();
            DataGrid1.DataBind();        DataGrid2.DataSource = di.GetFiles();
            DataGrid2.DataBind();        ViewState["ParentPath"] = di.Parent.FullName;
            ViewState["CurrentPath"] = DiskPath;
            //ViewState["ParentPath"] = Server.MapPath("..");    }    void Button1_Click(object sender, EventArgs e) {
            DirectoryInfo di = new DirectoryInfo(ViewState["CurrentPath"].ToString());
            string SubDirName = tbxDirectoryName.Text.Trim();
            di.CreateSubdirectory(SubDirName);        DataGrid1.DataSource = di.GetDirectories();
            DataGrid1.DataBind();
        }    void DataGrid1_SelectedIndexChanged(object sender, EventArgs e) {    }    void DataGrid1_EditCommand(object sender, DataGridCommandEventArgs e) {
            string DiskPath = e.Item.Cells[0].Text.Trim();
            BindDiskInfo(DiskPath);
        }    void Button2_Click(object sender, EventArgs e) {
            if(lblRootPath.Text.Length > ViewState["ParentPath"].ToString().Length)
            {
                return;
            }
            BindDiskInfo(ViewState["ParentPath"].ToString());
        }    void Button3_Click(object sender, EventArgs e) {
            string ClientFileName = upFile.Value;
            string[] TempArr =  ClientFileName.Split("\\".ToCharArray());
            string ClientFileExtendName = TempArr[TempArr.Length - 1];        string SaveFileName = ClientFileExtendName;
            upFile.PostedFile.SaveAs(Server.MapPath(SaveFileName));        BindDiskInfo(ViewState["CurrentPath"].ToString());
        }</script>
    <html>
    <head>
    </head>
    <body>
        <form runat="server">
            <!-- Insert content here --><asp:Label id="lblRootPath" runat="server" forecolor="#cceeaa" font-size="Larger" backcolor="Blue"></asp:Label>
            <table style="BORDER-RIGHT: blue 1px solid; BORDER-TOP: blue 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: blue 1px solid; BORDER-BOTTOM: blue 1px solid" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tbody>
                    <tr>
                        <td width="320">
                            <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged" OnEditCommand="DataGrid1_EditCommand">
                                <Columns>
                                    <asp:BoundColumn DataField="FullName" HeaderText="文件夹"></asp:BoundColumn>
                                    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="进入"></asp:EditCommandColumn>
                                </Columns>
                            </asp:DataGrid>
                            <br />
                            <div style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid">
                                <asp:TextBox id="tbxDirectoryName" runat="server"></asp:TextBox>
                                <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="NewDir"></asp:Button>
                                <asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="ToParent"></asp:Button>
                                <br />
                                <input id="upFile" type="file" runat="server" />
                                <asp:Button id="Button3" onclick="Button3_Click" runat="server" Text="Save"></asp:Button>
                            </div>
                        </td>
                        <td width="2" bgcolor="#aaccee">
                            &nbsp;
                        </td>
                        <td>
                            <asp:DataGrid id="DataGrid2" runat="server" AutoGenerateColumns="False">
                                <Columns>
                                    <asp:BoundColumn DataField="Name" HeaderText="文件名"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="Length" HeaderText="大小"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="LastWriteTime" HeaderText="最后更新时间"></asp:BoundColumn>
                                     <asp:TemplateColumn>
                                        
                                        <ItemTemplate>
                                            <a target="_blank" href='<%#DataBinder.Eval(Container.DataItem,"Name")%>'>浏览</a> 
                                        </ItemTemplate>
                                    </asp:TemplateColumn>
                                </Columns>
                            </asp:DataGrid>
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </body>
    </html>
      

  16.   

    发EMAIL给我,我传全套代码给你.
      

  17.   

    to:drk928(一起看斜阳)
    非常感谢!!
    [email protected]
      

  18.   

    我找到一个办法。是浏览本机的。
    http://www.cnblogs.com/wssmax/archive/2005/06/03/167329.html
      

  19.   

    刚刚那个额可以浏览服务器
    这个浏览本机
    http://www.cnblogs.com/wssmax/archive/2005/06/03/167342.html
      

  20.   

    找了半天了,也发给我吧,wenxinwenyi2163.net,谢谢
      

  21.   

    IE里本身就有这样一个组件的,可以调用它。我以前看到过MS有一个示例,里面就可以实现这些,包括调色板等功能。不过一时我找不到。
      

  22.   

    ms-help://MS.MSDNQTR.2003FEB.2052/dhtml/workshop/author/editing/tutorials/html_editor.htm这里有就这样一个例子。你打开最后一个show me 按钮