コード例 #1
0
        public void CopyFile(object obj)
        {
            CopyFileInfo c = obj as CopyFileInfo;

            byte[] fromb = File.ReadAllBytes(c.From);
            File.WriteAllBytes(c.To, fromb);
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedPath == null)
            {
                MessageBox.Show("Please select a folder to save images.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            foreach (InfoProperties ip in IpList)
            {
                LandscapeImage landscapeImage = ip.LandscapeImage;
                PortraitImage  portraitImage  = ip.PortraitImage;
                string         li             = landscapeImage.Image;
                string         pi             = portraitImage.Image;
                //线程异步调用复制文件
                Thread cp1   = new Thread(new ParameterizedThreadStart(CopyFile));
                int    pos1  = li.LastIndexOf("\\");
                string name1 = li.Substring(pos1 + 1);
                object o1    = new CopyFileInfo()
                {
                    From = li,
                    To   = SelectedPath + "\\" + name1 + ".jpg"
                };
                cp1.Start(o1);

                Thread cp2   = new Thread(new ParameterizedThreadStart(CopyFile));
                int    pos2  = pi.LastIndexOf("\\");
                string name2 = pi.Substring(pos2 + 1);
                object o2    = new CopyFileInfo()
                {
                    From = pi,
                    To   = SelectedPath + "\\" + name2 + ".jpg"
                };
                cp2.Start(o2);

                MessageBox.Show("Save Images success!", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }