Пример #1
0
        static void Main(string[] args)
        {
            var folderPath = ConfigurationManager.AppSettings["sourcePath"];

            FileTypes = new List <string> {
                "*.*"                           /*,  */
            };
            VideoTypes = ConfigurationManager.AppSettings["videoTypes"].Split(',', ';', ' ').Where(f => !string.IsNullOrEmpty(f)).Select(f => f.Trim()).ToList();
            PicTypes   = ConfigurationManager.AppSettings["picTypes"].Split(',', ';', ' ').Where(f => !string.IsNullOrEmpty(f)).Select(f => f.Trim()).ToList();

            var files = new List <string>();

            foreach (var ft in FileTypes)
            {
                files.AddRange(Directory.GetFiles(folderPath, ft, SearchOption.AllDirectories));
            }

            var drive = ConfigurationManager.AppSettings["drive"];

            var destPic   = ConfigurationManager.AppSettings["destPic"];
            var destVid   = ConfigurationManager.AppSettings["destVid"];
            var destOther = ConfigurationManager.AppSettings["destOther"];

            var sourcePics   = files.Where(f => PicTypes.Any(p => f.EndsWith(p)));
            var sourceVideos = files.Where(f => VideoTypes.Any(p => f.EndsWith(p)));
            var otherFiles   = files.Where(f => !(PicTypes.Any(p => f.EndsWith(p)) || VideoTypes.Any(p => f.EndsWith(p))));


            var s1 = DateTime.Now;

            Console.WriteLine("Pictures copy started...");
            CopyFiles(drive, destPic, sourcePics);
            var s2 = DateTime.Now;

            Console.WriteLine(string.Format("Pictures copied: {0} sec", (s2 - s1).TotalSeconds.ToString()));

            Console.WriteLine("Videos copy started...");
            CopyFiles(drive, destVid, sourceVideos);
            var s3 = DateTime.Now;

            Console.WriteLine(string.Format("Videos copied: {0} sec", (s3 - s2).TotalSeconds.ToString()));

            Console.WriteLine("Other files copy started...");
            CopyFiles(drive, destOther, otherFiles);
            var s4 = DateTime.Now;

            Console.WriteLine(string.Format("Other files copied: {0} sec", (s4 - s3).TotalSeconds.ToString()));

            LogProblems();

            Console.ReadKey();
        }
Пример #2
0
 /// <summary>
 /// Get the desired picture object to display
 /// </summary>
 /// <param name="type">Enum type that defines which picture to return</param>
 /// <returns>Bitmap object bound to given picture</returns>
 public static Image GetPicture(PicTypes type)
 {
     String filename;
     switch (type)
     {
         case PicTypes.SAD_PIC:
             filename = "Resources\\Pictures\\lonely.jpg";
             break;
         default:
             filename = "Resources\\Pictures\\vuvuzela_red.jpg";
             break;
     }
     return ( new Bitmap(filename) );
 }