如何在c#windows窗体中创建文件夹

cha*_*ndu 0 c# winforms

如何在计算机中安装解决方案时自动创建文件夹,即(本地磁盘:D)使用c#windows窗体?

Owa*_*shi 12

解决方案1:

在第一次运行应用程序时(创建一个xml文件来跟踪第一次执行),您可以创建文件夹.

解决方案#2 :(好的)您可以检查该目录是否存在,如果不存在则创建目录

     try
    {
    // If the directory doesn't exist, create it.
    if (!Directory.Exists(palettesPath))
    {
        Directory.CreateDirectory(palettesPath);
    }
    }
    catch (Exception)
    {
    // Fail silently
    }
Run Code Online (Sandbox Code Playgroud)

来源: 查看此链接