Skip to content

Instantly share code, notes, and snippets.

@NickersF
Last active August 29, 2015 14:12
Show Gist options
  • Save NickersF/beb3cef271351e131be3 to your computer and use it in GitHub Desktop.
Save NickersF/beb3cef271351e131be3 to your computer and use it in GitHub Desktop.
Creating a basic C# app that makes a template of folders for web sites.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace createWebSiteStructure
{
class Program
{
static void Main(string[] args)
{
// Get an input for the folder name
Console.WriteLine("Enter a Folder name:");
string usrFolderName = Console.ReadLine();
// Starting top-level directory where the new folder will be created.
string activeDir = @"C:\Users\Nick\Documents\My Web Sites\";
// Create the new sub-folder under the current active folder
string newPath = System.IO.Path.Combine(activeDir, usrFolderName);
// Create the sub folder
System.IO.Directory.CreateDirectory(newPath);
//Create the four sub folders 'css' 'scripts' 'img' 'snippets'.
string activeSubDir = newPath;
string subPath = System.IO.Path.Combine(activeSubDir, "css");
string subPath1 = System.IO.Path.Combine(activeSubDir, "img");
string subPath2 = System.IO.Path.Combine(activeSubDir, "scripts");
string subPath3 = System.IO.Path.Combine(activeSubDir, "snippets");
System.IO.Directory.CreateDirectory(subPath);
System.IO.Directory.CreateDirectory(subPath1);
System.IO.Directory.CreateDirectory(subPath2);
System.IO.Directory.CreateDirectory(subPath3);
// Write a confirmation to the console
string confirmCreate = System.IO.Path.GetDirectoryName(subPath);
Console.WriteLine("Succesfully create the web site folder template: {0}", confirmCreate);
// Exit Message
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment