Beispiel #1
0
        public List <FileForS3> ReadAllFiles()
        {
            List <FileForS3> fileList = new List <FileForS3>();
            string           path     = GetPathFromConfig();

            List <Task> taskList = new List <Task>();

            //Por cada fichero en el path
            foreach (string file in Directory.EnumerateFiles(path))
            {
                var task = Task.Factory.StartNew(() => {
                    FileForS3 f4s3 = new FileForS3();
                    f4s3.path      = file;
                    f4s3.type      = FileForS3.ContentTypeSet(f4s3);
                    fileList.Add(f4s3);
                    log.Info("File {0} read from disk" + f4s3.path);
                });

                taskList.Add(task);
            }

            Task.WaitAll(taskList.ToArray());
            log.Info("All file were read.");

            return(fileList);
        }
Beispiel #2
0
        public static string ContentTypeSet(FileForS3 file)
        {
            string extension = Path.GetExtension(file.path);

            switch (extension)
            {
            case "txt":
                return("");

            default:
                return("");
            }
        }