请问怎样在listBox里添加指定盘下的目录文件夹名啊???

nizhuohong 2008-11-02 04:03:13
请问怎样在listBox里添加指定盘下的目录文件夹名啊???
...全文
99 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
王集鹄 2008-11-02
  • 打赏
  • 举报
回复
参考如下代码:
private void button1_Click(object sender, EventArgs e)
{
//using System.IO;
string directory = @"c:\windows\system32";
foreach (string sub in Directory.GetDirectories(directory))
{
listBox1.Items.Add(Path.GetFileName(sub)); // GetFileName()将路径去掉
}
}

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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