Пример #1
0
        public MainViewModel()
        {
            RapiComm.Ping();

            RapiComm.OnConnected              += new EventHandler(RapiComm_OnConnected);
            RapiComm.OnDisconnected           += new EventHandler(RapiComm_OnDisconnected);
            RapiComm.OnConnectingStateChanged += new EventHandler(RapiComm_OnConnectingStateChanged);
            //RapiComm.On
        }
Пример #2
0
        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", "");
            }
        }