Click here to Skip to main content
15,886,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm new to programming and would most appreciate some help. I would like to know how I could create folders within folders. I have a root directory and inside exist folders, with multiple folders - Client, then inside each client directory is a To and From Folder - inside those folders exists more folders. I would like to create a program that would enable me a way to create folders quickly.

I.E. Drive\Home\Client\To\Folder\Folder1
Drive\Home\Client\From\Folder\Folder1


Thanks, any help would be appreciated.



**** Update - in an attempt to clarify a bit

I have a FTP Network Drive that has a shard folder, inside of that folder is more folders which are clients folders. Inside each client folder is two folders - To and From. Inside of the To and From folders are more folders - these are where clients will place files or pick up files. Therefore, I would like to script something that would only place a folder in either the To or From Folders. It would need to be able to do this for all 1000+ client folders, it would also need to print out a report of what folder was placed and where, and if the folder already exists, then it would need to notify as such and not place a folder, Ideally, if the folder exists, let's say name spelled incorrectly, then script would be able to either correct the name or create a new folder and copy old folder contents to new folder and then delete old folder. I know this is a bit much, however, as present, I manually go thru 1000+ folders adding a folder each time one is needed. Help, please..........
Posted
Updated 13-Jan-10 16:35pm
v2

1 solution

how about something like this:

static void Main(string[] args)
        {
            CreateFoldersFromPath(@"C:\manas\hello\abc");
        }

        private static void CreateFoldersFromPath(string PstrPath)
        {
            string LstrPath = PstrPath.Substring(0, 2);
            string[] LlstFolders = PstrPath.Remove(0, 3).Split('\\');

            for (int LiCount = 0; LiCount < LlstFolders.Length; LiCount++)
            {
                if (!Directory.Exists(LstrPath + LlstFolders[LiCount]))
                {
                    LstrPath = string.Format(@"{0}\{1}", LstrPath, LlstFolders[LiCount]);
                    Directory.CreateDirectory(LstrPath);
                }
            }
        }


Lets say you pass the C:\Drive\Home\Client\To\Folder\Folder1 to the function and it will create it for you.

You can take it as a start point and see if it helps.:rose:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900