示例#1
0
        private void CreateFilesInFolder(string folder, int folderDepth)
        {
            // Create files
            for (int fileCounter = 1; fileCounter <= Config.FilesPerFolder; fileCounter++)
            {
                string filePath = FileEx.CombinePath(folder, $"TestFile-{fileCounter}.tmp");
                WriteFile(filePath);
            }

            // Stop recursion
            if (folderDepth == 0)
            {
                return;
            }

            // Recursively create folders
            for (int folderCounter = 1; folderCounter <= Config.FoldersPerFolder; folderCounter++)
            {
                // Create child folder
                string childFolder = FileEx.CombinePath(folder, $"TestFolder-{folderCounter}");
                FileEx.CreateDirectory(childFolder);

                // Recursively create files and folders
                CreateFilesInFolder(childFolder, folderDepth - 1);
            }
        }