Beispiel #1
0
 public Service1()
 {
     InitializeComponent();
     sync = new BlinkSyncLib.Sync(@"C:\Blink\Target", @"C:\Blink\Source");
 }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //copy the folder into source(encrypted) and sync the source with target
            //before copying the folder into source i will make an entry in fileVault about the current user and the filename in the source folder



            if (currentInputFile == null)
            {
                MessageBox.Show("Select Target File", "Error!");
                return;
            }

            //step 1 make entry in the vault


            string fileToCopy;

            string[] breakApartCurrFile = currentInputFile.Split('.');
            fileToCopy = breakApartCurrFile[0] + ".e" + breakApartCurrFile[1];

            string[] breakApartSlash = breakApartCurrFile[0].Split('\\');

            string uriInSafe = @"C:\Blink\Source\" + breakApartSlash[breakApartSlash.Length - 1];

            try
            {
                XDocument doc  = XDocument.Load(@"C:\Users\sohan\onedrive\documents\visual studio 2015\Projects\ARP_read02\ARP_read02\assets\fileVault.xml");
                XElement  root = new XElement("file");

                root.Add(new XAttribute("uriOutSafe", currentInputFile));
                root.Add(new XAttribute("uriInSafe", uriInSafe));
                root.Add(new XAttribute("user", MyService.macAddressForEncryption));

                //change mac address to something permanent during RPC
                //root.Add(new XAttribute("user", myMac));



                doc.Element("vault").Add(root);
                doc.Save(@"C:\Users\sohan\onedrive\documents\visual studio 2015\Projects\ARP_read02\ARP_read02\assets\fileVault.xml");
            }
            catch (Exception ex)
            {
                //return error messgae at RPC
                Console.WriteLine(ex.Message);
            }

            //string[] breakApartSlash[];



            EncryptTargetFile(currentInputFile, breakApartCurrFile[0] + ".e" + breakApartCurrFile[1]);

            //delete the currentInputFile and move the encrypted file to source and sync source with target
            if (File.Exists(currentInputFile))
            {
                File.Delete(currentInputFile);
            }
            File.Move(fileToCopy, uriInSafe);
            File.Delete(fileToCopy);


            BlinkSyncLib.Sync sync = new BlinkSyncLib.Sync(@"C:\Blink\Target", @"C:\Blink\Source");
            sync.Start();
            sync = new BlinkSyncLib.Sync(@"C:\Blink\Source", @"C:\Blink\Target");
            sync.Start();
        }