Two Questions

Question #1: Is it possible to have a restart code rather than:

System.Diagnostics.Process.Start("restart", "-r -t 05");

Question #2: Can someone help me edit the code below I wish to make this make code create the folders more than once. What I mean is, at the moment, I am using this code on the press of "OK". Once I press "OK" it creates the folders, but if I press "OK" again, it doesn't create anymore folders, the problem is because the folders are already created and it can't over-write. Is there a way to make it create like "TEST1-1" or continue with the number last used


for (int i = 0; i < 5; i++) 
{
System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Test" + i.ToString());
}



Answer this question

Two Questions

  • NBaig

    int times=0;

    buttonOK_click(...,...)

    {

    for (int i = 0; i < 5; i++)
    {
    System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Test" +times.ToString()+ i.Tostring());
    }

    times++;

    }

    hope that help you

    DongMT, VietNam



  • jeskey

    Neither really helps me. I get compile errors. I'm programming in C# btw if tahts a problem.


  • BRAD.Marsh

    or just use the current Date/Time to create the folders again, the date/time being the values to use to set the folder name...without having to do a for loop :-)

    Question #1: Is it possible to have a restart code rather than:

    System.Diagnostics.Process.Start("restart", "-r -t 05");

    not sure I quite follow, can you explain further restart what



  • vtortola

    IN your first question you are probably refering to computer Restart! Right See Here:

    http://www.pinvoke.net/search.aspx search=ShutDown&namespace=[All]

    Best Regards,



  • Ivo6070

    Is this what your're looking for

    int n = 0, counter = 0;
    string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) ;
    while(counter < 5)
    {
    string path = Path.Combine(folderPath, "Test" + n++) ;
    if (!Directory.Exists(path))
    {
    Directory.CreateDirectory(path);
    counter++;
    }
    }

    JK

  • Brandon Tucker

    Add the following to the top of the page:

    using System.IO;

  • Two Questions