建立资料夹 [英] Create Folders

查看:140
本文介绍了建立资料夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,非常感谢您的帮助.我想知道如何在文件夹中创建文件夹.我有一个根目录,并且在存在的文件夹中有多个文件夹-客户端,然后在每个客户端目录中都有一个收件人"和从"文件夹-这些文件夹中存在更多文件夹.我想创建一个程序,使我可以快速创建文件夹.

IE. Drive \ Home \ Client \ To \ Folder \ Folder1
驱动器\主目录\客户端\发件人\文件夹\文件夹1


谢谢,任何帮助将不胜感激.



****更新-试图澄清一下

我有一个具有分片文件夹的FTP网络驱动器,在该文件夹内是更多文件夹,它们是客户端文件夹.每个客户端文件夹中都有两个文件夹-收件人和发件人.在收件人"和发件人"文件夹中有更多文件夹-客户端将在这些文件夹中放置文件或拾取文件.因此,我想编写只在收件人"或从文件夹"中放置一个文件夹的脚本.它将需要能够对所有1000多个客户端文件夹执行此操作,还需要打印出有关放置了哪个文件夹以及放置位置的报告,如果该文件夹已经存在,则需要照此进行通知,而不是进行通知.放置一个文件夹,理想情况下,如果该文件夹存在,假设名称拼写不正确,那么脚本将能够更正名称或创建新文件夹,然后将旧文件夹内容复制到新文件夹,然后删除旧文件夹.我知道这有点多,但是,就目前而言,每次需要一个文件夹时,我都会手动通过1000多个文件夹来添加一个文件夹.帮助,请..........

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..........

推荐答案

这样的事情如何:

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);
                }
            }
        }



假设您将C:\ Drive \ Home \ Client \ To \ Folder \ Folder1传递给该函数,它将为您创建它.

您可以将其作为起点,看看是否有帮助.:rose:



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:


这篇关于建立资料夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆