asp.net 有一个自带的 FileUpload 文件上传控件,这个只能选择一个文件却不能选择一个文件夹我想实现的是选择一个文件夹点确定后获取这个文件夹的绝对地址,这个怎么实现,到网上找了好多资料但都不行,更奇怪的是在网上找了一段代码后,弹出的对话框的中间却没有选择文件一项,其它如新建文件夹,确定和取消按钮都有,就是没有中间选择文件夹的部分,不知为什么,下面是这段代码,请大家帮忙看一下 //创建FolderBrowserDialog类的实例
FolderBrowserDialog fbd = new FolderBrowserDialog(); //指定上面部分的说明Text
fbd.Description = "请指定文件夹。";
//指定根目录
//根目录为Desktop
fbd.RootFolder = Environment.SpecialFolder.Desktop;
//指定初始化目录
//RootFolder以下的文件夹是有必要的
fbd.SelectedPath = @"C:\Windows";
//为了用户能创建新的文件夹
//默认为True
fbd.ShowNewFolderButton = true; //显示对话框
if (fbd.ShowDialog() == DialogResult.OK)
{
//显示选定的文件夹
Console.WriteLine(fbd.SelectedPath);
}
解决方案 »
- 找不到可安装的ISAM
- 请问一下,如何能获取客户端可用的URL??
- 文件下载问题!!!
- 你们有用户控件(ascx控件)方面的学习资料,或示例吗?给一份,好吗?谢谢
- 求一解决方法:B/S软件注册后才可以使用?
- javascript和.net(在线)
- [共享]C#编码标准 & .NET Framework相关的指南
- 怎样把一个.swf文件动态放在HtmlTableCell中?(在线)
- DataGrid的编辑问题
- 关于.NET的编译
- 怪问题:用response.redirect("a.aspx?name="+username),这个username只能传2个中文字,3个中文字就出现乱码?
- 关于一个弹出对话框的简单问题
var Shell = new ActiveXObject( "Shell.Application" );
var Folder = Shell.BrowseForFolder(0,Message,0x0040,0x11);//起始目录为:我的电脑
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:fileupload runat="server" ID="fileupload1"></asp:fileupload>
<asp:Button ID="BtnGetDirPath" runat="server" Text="获取目录名字"
onclick="BtnGetDirPath_Click" />
</div>
</form>
</body></html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class _20100824_2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void BtnGetDirPath_Click(object sender, EventArgs e)
{
if (this.fileupload1.HasFile)
{
string path = this.fileupload1.FileName;
string Dirpath = this.fileupload1.PostedFile.FileName.Replace(path,"");
Response.Write("您选的目录名称是:"+Dirpath);
}
}
}哥的工具是VS2008