如何实现WinForm的FolderBrowerDialog

firein 2010-03-19 01:23:36
我想实现WinForm的FolderBrowerDialog的效果,即打开一个文件夹选择框,能选择服务器或本地的某一个文件夹。
请帖出完整代码,谢谢
...全文
223 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
firein 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 cpp2017 的回复:]
需求分析在软件开发中是很重要的一环,如果对用户的原始需求不是很清晰或是对技术架构理解的不够深刻,
会产生一些错误或是不正常的技术需求,
这会让软件开发走不少弯路。
[/Quote]

恩 学习
cpp2017 2010-03-19
  • 打赏
  • 举报
回复
需求分析在软件开发中是很重要的一环,如果对用户的原始需求不是很清晰或是对技术架构理解的不够深刻,
会产生一些错误或是不正常的技术需求,
这会让软件开发走不少弯路。
qlzf11140820 2010-03-19
  • 打赏
  • 举报
回复
帮顶.....能实现FolderBrowerDialog吗
cpp2017 2010-03-19
  • 打赏
  • 举报
回复
本地只能使用<input type="file"方式。
firein 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 cpp2017 的回复:]
C# code
protected void Page_Load(object sender, EventArgs e)
{

TreeNode rootNode = new TreeNode();
this.TreeView1.Nodes.Add(rootNode);
ShowFolder(Ser……
[/Quote]
谢谢回复
但是这样还是不符合要求,我想是要那种能打开本地又能打开局域网内的又能打开服务器的文件夹。。。
cpp2017 2010-03-19
  • 打赏
  • 举报
回复
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);
}
}
firein 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cpp2017 的回复:]
是用asp.net么?如果是,用TreeVeiw遍历服务器上的文件夹和文件,
[/Quote]
firein 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 okidasougo 的回复:]
C# code

private void saveList()
{
ArrayList list = new ArrayList();

SaveFileDialog save = new SaveFileDialog();

save.Filter = "(*.Lst)|*.……
[/Quote]

asp.net里不能用openfiledialog和FolderBrowerDialog
firein 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jelly_tracy 的回复:]
fileupload ,浏览就能选择...上传图片
[/Quote]
这个只能选择文件
okidasougo 2010-03-19
  • 打赏
  • 举报
回复

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);
}
}


}
Jelly_tracy 2010-03-19
  • 打赏
  • 举报
回复
或者一些其他的第三方控件也有类似的功能
cpp2017 2010-03-19
  • 打赏
  • 举报
回复
是用asp.net么?如果是,用TreeVeiw遍历服务器上的文件夹和文件,

Jelly_tracy 2010-03-19
  • 打赏
  • 举报
回复
fileupload ,浏览就能选择...上传图片

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧