Ejemplo n.º 1
0
        private void CopyImageAndXml(FeedItem fi, string TargetPath)
        {
            if (!(TargetPath.EndsWith("\\") || TargetPath.EndsWith("/")))
            {
                TargetPath += '\\';
            }
            string path = System.IO.Path.GetDirectoryName(fi.LocalImage);
            string file = System.IO.Path.GetFileName(fi.LocalImage);

            int    index      = path.LastIndexOf('\\');
            string datefolder = path.Substring(index + 1);

            string targetdir = TargetPath + datefolder + '\\';

            if (!System.IO.Directory.Exists(targetdir))
            {
                System.IO.Directory.CreateDirectory(targetdir);
            }

            File.Copy(fi.LocalImage, targetdir + file, true);
            File.Copy(path + "\\feed.xml", targetdir + "feed.xml", true);
        }
Ejemplo n.º 2
0
        private Task CopyMovie(FeedItem fi, ProgressBar pb, string TargetPath)
        {
            if (!(TargetPath.EndsWith("\\") || TargetPath.EndsWith("/")))
            {
                TargetPath += '\\';
            }
            string path = System.IO.Path.GetDirectoryName(fi.LocalMovie);
            string file = System.IO.Path.GetFileName(fi.LocalMovie);

            int    index      = path.LastIndexOf('\\');
            string datefolder = path.Substring(index + 1);

            string targetdir = TargetPath + datefolder + '\\';

            if (!System.IO.Directory.Exists(targetdir))
            {
                System.IO.Directory.CreateDirectory(targetdir);
            }

            FileCopier fc = new FileCopier(fi.LocalMovie, targetdir + file);

            fc.OnProgressChanged += (percentage) =>
            {
                Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => pb.Value = percentage));
            };

            fc.OnComplete += (() =>
            {
                Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => pb.Visibility = Visibility.Hidden));
            });

            return(Task.Run(() =>
            {
                fc.Copy();
            }));
        }