110,572
社区成员
发帖
与我相关
我的任务
分享
using system.io;
Button preButton = null;
Button bt;
DirectoryInfo dinfo = new DirectoryInfo(@"F:\abc");
foreach(FileInfo finfo in dinfo.GetFiles())
{
bt = new Button();
if(preButton!=null)
{
bt.Location = new Point(10, 30 + preButton.Top);
}
else
{
bt.Location = new Point(10, 30);
}
bt.Text = finfo.Name;
bt.Click += new EventHandler(click_button);
this.Controls.Add(bt);
preButton = bt;
}
foreach(DirectoryInfo d_info in dinfo.GetDirectories())
{
//和上面差不多
}
protected void click_button(object sender, EventArgs e)
{
//打开文件
}