feiyucha

实现效果:

  

知识运用:

  Guid结构的NewGuid方法  //用来初始化Guid结构的一个新实例

  public static Guid NewGuid ()    //返回值: 新的Guid对象

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog P_fb = new FolderBrowserDialog();
            if (P_fb.ShowDialog() == DialogResult.OK)
            {
                File.Create(P_fb.SelectedPath+"\\"+
                    Guid.NewGuid().ToString()+".txt");  //根据GUID生成文件名
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog P_fb = new FolderBrowserDialog();
            if (P_fb.ShowDialog() == DialogResult.OK)
            {
                Directory.CreateDirectory(P_fb.SelectedPath + "\\" +
                    Guid.NewGuid().ToString());         //根据GUID生成文件夹
            }
        }

  

分类:

技术点:

相关文章:

  • 2021-12-22
  • 2021-12-19
  • 2021-12-09
  • 2021-12-07
  • 2021-12-02
  • 2021-08-27
  • 2021-10-15
猜你喜欢
  • 2021-12-13
  • 2021-11-06
  • 2022-01-01
  • 2021-10-18
  • 2021-09-13
  • 2021-11-29
  • 2021-12-25
相关资源
相似解决方案