예제 #1
0
        public void CheckDirectories(string directory)
        {
            var directories = Directory.GetDirectories(directory);

            if (directories.Any())
            {
                foreach (var dir in directories)
                {
                    CheckDirectories(dir);
                }
            }

            var extensions = ExtensionsToListenFor.Split(',');

            var files = Directory.GetFiles(directory)
                        .Where(a => extensions.Contains(Path.GetExtension(a).ToLower()))
                        .ToList();

            //if (!files.Any(a => !Path.GetFileName(a).Equals("success.converted")))
            //{
            //    FilesToConvert.AddRange(files);
            //}

            if (!File.Exists(Path.Combine(directory, "success.converted")))
            {
                foreach (var file in files)
                {
                    if (!File.Exists(file + ".converted"))
                    {
                        FilesToConvert.Add(file);
                    }
                }
            }
        }
예제 #2
0
        protected override void OnStart(string[] args)
        {
            var filters = ExtensionsToListenFor.Split(new string[] { "|", "," }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var filter in filters)
            {
                var fileSystemWatcher = new FileSystemWatcher();

                fileSystemWatcher.Path = SourceDirctory;

                fileSystemWatcher.IncludeSubdirectories = true;

                fileSystemWatcher.Filter = filter;

                fileSystemWatcher.EnableRaisingEvents = true;

                fileSystemWatcher.Created += FileSystemWatcher_Created;

                Watchers.Add(fileSystemWatcher);
            }

            ExecuteHandbrake();
        }