コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: dynamics7/wpbackup
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            if (RapiComm.IsConnected)
            {
                var tempPath = System.Windows.Forms.Application.StartupPath + "\\Test3";
                var list     = RapiComm.CopyDirectoryFromDeviceFLAT("\\My Documents", tempPath, "");

                var fb = new FlatBackup();
                foreach (var item in list.Values)
                {
                    fb.AddEntry(item, true);
                    //fb.List.Add((item.IsFolder ? "dir" : item.InternalPath), item);
                    Console.WriteLine((item.IsFolder ? "dir" : item.InternalPath) + "=" + item.DeviceSidePath);
                }
                fb.Write(System.Windows.Forms.Application.StartupPath + "\\test.zip", "");
            }
            else
            {
                var fb = new FlatBackup();
                fb.Read(System.Windows.Forms.Application.StartupPath + "\\test.zip");
                var tempPath = "C:\\Temp\\WPBackup";
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }
                foreach (var item in fb.List)
                {
                    var file = item.Value;
                    Console.WriteLine("\"" + file.InternalPath + "|||" + file.DeviceSidePath + "\"");
                    if (file.IsFolder)
                    {
                        if (!Directory.Exists(tempPath + "\\" + file.DeviceSidePath))
                        {
                            Directory.CreateDirectory(tempPath + "\\" + file.DeviceSidePath);
                        }
                    }
                    else if (fb.File[file.InternalPath] != null)
                    {
                        var directory = Path.GetDirectoryName(file.DeviceSidePath);
                        if (!Directory.Exists(tempPath + "\\" + directory))
                        {
                            Directory.CreateDirectory(tempPath + "\\" + directory);
                        }
                        var stream = new FileStream(tempPath + "\\" + file.DeviceSidePath, FileMode.Create, FileAccess.Write);
                        fb.Extract(file, stream);
                        stream.Close();
                        file.PcSidePath = tempPath + "\\" + file.DeviceSidePath;
                    }
                }
                fb.AddEntry(System.Windows.Forms.Application.StartupPath + "\\PresentationCore.dll", "\\Applications\\PresentationCore.dll", false, true);
                fb.AddEntry("", "\\TestFolder", true, true);
                fb.Write(System.Windows.Forms.Application.StartupPath + "\\test.zip", "");
            }
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: dynamics7/wpbackup
        private void LoadBackupThread(object param)
        {
            lock (_loadBackupSync)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    IsLoadingBackup = true;
                }));
                _tempFile     = null;
                _tempFilePath = null;
                //Thread.Sleep(5000);
                try
                {
                    string fileName = param as string;
                    if (ZipFile.IsZipFile(fileName))
                    {
                        //ZipFile file = new ZipFile(fileName);
                        FlatBackup file = new FlatBackup();
                        file.Read(fileName);
                        _tempFile     = file;
                        _tempFilePath = fileName;
                    }
                }
                catch (Exception ex)
                {
                    _tempFile     = null;
                    _tempFilePath = null;
                }

                Application.Current.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    if (OnTempFileLoaded != null)
                    {
                        OnTempFileLoaded(this, new EventArgs());
                    }
                    IsLoadingBackup = false;
                }));
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ultrashot/wpbackup
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            if (RapiComm.IsConnected)
            {
                var tempPath = System.Windows.Forms.Application.StartupPath + "\\Test3";
                var list = RapiComm.CopyDirectoryFromDeviceFLAT("\\My Documents", tempPath, "");

                var fb = new FlatBackup();
                foreach (var item in list.Values)
                {
                    fb.AddEntry(item, true);
                    //fb.List.Add((item.IsFolder ? "dir" : item.InternalPath), item);
                    Console.WriteLine((item.IsFolder ? "dir" : item.InternalPath) + "=" + item.DeviceSidePath);
                }
                fb.Write(System.Windows.Forms.Application.StartupPath + "\\test.zip", "");
            }
            else
            {
                var fb = new FlatBackup();
                fb.Read(System.Windows.Forms.Application.StartupPath + "\\test.zip");
                var tempPath = "C:\\Temp\\WPBackup";
                if (!Directory.Exists(tempPath))
                    Directory.CreateDirectory(tempPath);
                foreach (var item in fb.List)
                {
                    var file = item.Value;
                    Console.WriteLine("\"" + file.InternalPath + "|||" + file.DeviceSidePath + "\"");
                    if (file.IsFolder)
                    {
                        if (!Directory.Exists(tempPath + "\\" + file.DeviceSidePath))
                            Directory.CreateDirectory(tempPath + "\\" + file.DeviceSidePath);
                    }
                    else if (fb.File[file.InternalPath] != null)
                    {
                        var directory = Path.GetDirectoryName(file.DeviceSidePath);
                        if (!Directory.Exists(tempPath + "\\" + directory))
                            Directory.CreateDirectory(tempPath + "\\" + directory);
                        var stream = new FileStream(tempPath + "\\" + file.DeviceSidePath, FileMode.Create, FileAccess.Write);
                        fb.Extract(file, stream);
                        stream.Close();
                        file.PcSidePath = tempPath + "\\" + file.DeviceSidePath;
                    }
                }
                fb.AddEntry(System.Windows.Forms.Application.StartupPath + "\\PresentationCore.dll", "\\Applications\\PresentationCore.dll", false, true);
                fb.AddEntry("", "\\TestFolder", true, true);
                fb.Write(System.Windows.Forms.Application.StartupPath + "\\test.zip", "");
            }
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: ultrashot/wpbackup
        private void LoadBackupThread(object param)
        {
            lock (_loadBackupSync)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    IsLoadingBackup = true;
                }));
                _tempFile = null;
                _tempFilePath = null;
                //Thread.Sleep(5000);
                try
                {

                    string fileName = param as string;
                    if (ZipFile.IsZipFile(fileName))
                    {
                        //ZipFile file = new ZipFile(fileName);
                        FlatBackup file = new FlatBackup();
                        file.Read(fileName);
                        _tempFile = file;
                        _tempFilePath = fileName;
                    }
                }
                catch (Exception ex)
                {
                    _tempFile = null;
                    _tempFilePath = null;
                }
                
                Application.Current.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    if (OnTempFileLoaded != null)
                        OnTempFileLoaded(this, new EventArgs());
                    IsLoadingBackup = false;
                }));
            }
        }