Esempio n. 1
0
        public static void ProcessTest(string path)
        {
            FileScanner scanner = new FileScanner();

            scanner.ItemScanned += ((sender, info) => {
                folderLogger.Info($"{info.Path}|{info.Size}|1|{info.ErrorMessage}|{DateTime.Now}");
            });

            scanner.FileScanned += ((sender, info) => {
                long size = 0;
                string err = String.Empty;

                try
                {
                    size = info.Length;
                }
                catch (Exception ex)
                {
                    err = ex.Message;
                }

                fileLogger.Info($"{info.FullName}|{size}|0|{err}|{DateTime.Now}");
            });

            DirectoryInfo dir = new DirectoryInfo(path);

            scanner.GetDirectorySize(dir);
        }
Esempio n. 2
0
        public static void PostItems(ITargetBlock <object> target, string path)
        {
            FileScanner scanner = new FileScanner();

            scanner.ItemScanned += ((sender, info) => {
                target.Post(info);
            });

            scanner.FileScanned += ((sender, info) => {
                target.Post(info);
            });

            DirectoryInfo dir = new DirectoryInfo(path);

            scanner.GetDirectorySize(dir);
        }