我想实现WinForm的FolderBrowerDialog的效果,即打开一个文件夹选择框,能选择服务器或本地的某一个文件夹。
请帖出完整代码,谢谢

解决方案 »

  1.   

    fileupload ,浏览就能选择...上传图片
      

  2.   

    是用asp.net么?如果是,用TreeVeiw遍历服务器上的文件夹和文件,
      

  3.   


            private void saveList()
            {
                ArrayList list = new ArrayList();            SaveFileDialog save = new SaveFileDialog();            save.Filter = "(*.Lst)|*.Lst";
                save.Title = "Save List";            if (save.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        foreach (ListViewItem item in this.listView1.Items)
                        {
                            list.Add(item);                    }
                        FileStream fs = new FileStream(save.FileName, FileMode.Create, FileAccess.Write);
                        BinaryFormatter bf = new BinaryFormatter();
                        bf.Serialize(fs, list);
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
         
            }
            private void openList()
            {
                OpenFileDialog open = new OpenFileDialog();            open.Title = "Load List";            if (open.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        this.listView1.Items.Clear();
                        FileStream fs = new FileStream(open.FileName, FileMode.Open, FileAccess.Read);
                        BinaryFormatter bf = new BinaryFormatter();
                        ArrayList conff = (ArrayList)bf.Deserialize(fs);
                        fs.Close();                    foreach (ListViewItem item in conff)
                        {
                            this.listView1.Items.Add(item);                    }
                    
                    }
                    catch (Exception ex)
                    {                    MessageBox.Show(ex.Message);
                    }
                }
            }
      

  4.   


    asp.net里不能用openfiledialog和FolderBrowerDialog
      

  5.   

    protected void Page_Load(object sender, EventArgs e)
            {            TreeNode rootNode = new TreeNode();
                this.TreeView1.Nodes.Add(rootNode);
                ShowFolder(Server.MapPath("~/"),ref rootNode);
            }
            void ShowFolder(string Path,ref TreeNode node)
            {
                node.Text = System.IO.Path.GetFileName(Path.TrimEnd('\\'));
                string[] Dirs = System.IO.Directory.GetDirectories(Path);
                foreach (string sDir in Dirs)
                {
                    TreeNode cNode = new TreeNode();
                    node.ChildNodes.Add(cNode);
                    ShowFolder(sDir, ref cNode);
                }
            }
      

  6.   

    本地只能使用<input type="file"方式。