コード例 #1
0
        //  Access Files from a directory
        private static async Task ProcessDirectory(string directoryPath, string fileType, CloudStorageAccount storageAccount)
        {
            switch (fileType)
            {
            case "txt":
                string[] files = Directory.GetFiles(directoryPath, ".txt");
                foreach (var filePath in files)
                {
                    var fileProcessor = new FileProcessor(filePath);
                    await fileProcessor.Process(storageAccount);
                }
                break;

            case "csv":
                string[] csvFiles = Directory.GetFiles(directoryPath, ".csv");
                foreach (var filePath in csvFiles)
                {
                    var fileProcessor = new FileProcessor(filePath);
                    await fileProcessor.Process(storageAccount);
                }
                break;

            case "json":
                string[] jsonFiles = Directory.GetFiles(directoryPath, ".json");
                foreach (var filePath in jsonFiles)
                {
                    var fileProcessor = new FileProcessor(filePath);
                    await fileProcessor.Process(storageAccount);
                }
                break;

            default:
                Console.WriteLine($"Error {fileType} is not supported!");
                break;
            }
        }
コード例 #2
0
 private static async Task ProcessSingleFile(string filePath, CloudStorageAccount storageAccount)
 {
     var fileProcessor = new FileProcessor(filePath);
     await fileProcessor.Process(storageAccount);
 }