you cannot do that on the server side in C#, you have to do it on the client side using scripting. Also, you need to enable ActiveX security settings on the client side machine, then try something like<script language="javascript">
var fso = new ActiveXObject("Scripting.FileSystemObject");function ShowFile(folder)
{
   var fc, s="";
   fc = new Enumerator(folder.files);
   for (; !fc.atEnd(); fc.moveNext())
   {
      s += fc.item();
      s += "<br>";
   }
   return(s);
}
function ShowFolderContent(folder)
{
   var fc, s;
   s = ShowFile(folder);
   fc = new Enumerator(folder.SubFolders);
   for (;!fc.atEnd(); fc.moveNext())
      {
         s += ShowFolderContent(fc.item());
         s += "<br>";
      }
      return(s);
}document.write(ShowFolderContent(fso.GetFolder("e:\\labs\\html")));
</script>

解决方案 »

  1.   

    刚好做了个例子,请看protected System.Web.UI.WebControls.ListBox ListData;string getpath="d:\\wwwroot\\post";   
    this.LblFilePath.Text=getpath;
    ProcessDirectory(ListData,getpath) ;
    public static  void ProcessDirectory(ListBox ListData,string targetDirectory) 
    {
    //Remove All ListBox Item  Frist
     // Recurse into subdirectories of this directory
    string [] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
     foreach(string subdirectory in subdirectoryEntries)
    //ProcessDirectory(subdirectory);
    ListData.Items.Add(subdirectory.Replace(targetDirectory+"\\","")+"  <目录>");
    // Process the list of files found in the directory
    string [] fileEntries = Directory.GetFiles(targetDirectory);
    foreach(string fileName in fileEntries)
    ListData.Items.Add(fileName.Replace(targetDirectory+"\\",""));
    }
      

  2.   

    谢谢各位,我是想做一个WEB上传管理软件,要和FTP工具一样,左边显示本地计算机上的目录,右边显示服务器上的文件.    服务器上的目录及文件我能显示并操作,但本地计算机在的文件我不知道如何显示及操作...    如一次性上传一个目录等...
      

  3.   

    好像只有显示服务器端,本地可能要用VB.NET
      

  4.   

    象思归说的,你不能用asp.net显示客户端的目录列表,这是客户端的安全设置所不允许的,你只能用客户端的scripting和ActiveX技术,但这同样要受安全限制。
      

  5.   

    private void ShowEmployee()
    {
    lstEmployee.Items.Clear() ; lstEmployee.DataSource = dsEmployee.Tables[0].DefaultView;
    lstEmployee.DataTextField = "FullName";
    lstEmployee.DataValueField ="EmployeeID";
    lstEmployee.DataBind();
    }
    lstEmployee为一个listbox名
    dsEmployee为一个DataSet
    DataTextField填写显示的字段名
    DataValueField填写隐藏字段名取值时lstEmployee.SelectedItem.Text (显示的)
    lstEmployee.SelectedItem.Value(隐藏)