Esempio n. 1
0
        public void copyFrom(Folder dir, LogXML log, SyncEntryJSON syncJSON)
        {
            File.Copy(dir.copyTo, fullPath);
            log.addFileEntry(dir.copyTo, "скопирован в", fullPath);
            EntryJSON entry = new EntryJSON(dir.copyTo, "скопирован в", fullPath);

            syncJSON.addFileEntry(entry);
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            logXML   = new LogXML();
            logJSON  = new LogJSON();
            syncJSON = new SyncEntryJSON();

            foreach (var file1 in dir1.files)
            {
                FileInformation currentFile1 = new FileInformation(file1);
                dir2.copyTo = Path.Combine(dir2.path, currentFile1.fileName);
                if (!File.Exists(dir2.copyTo))
                {
                    currentFile1.copyTo(dir2, logXML, syncJSON);
                }
                else
                {
                    FileInformation currentFile2 = new FileInformation(dir2.copyTo);
                    if (currentFile1.lastWriteTime >= currentFile2.lastWriteTime)
                    {
                        currentFile1.overwrite(dir2, logXML, syncJSON, 1);
                    }
                    else
                    {
                        currentFile1.overwrite(dir2, logXML, syncJSON, 2);
                    }
                }
                foreach (var file2 in dir2.files)
                {
                    FileInformation currentFile2 = new FileInformation(file2);
                    dir1.copyTo = Path.Combine(dir1.path, currentFile2.fileName);
                    if (!File.Exists(dir1.copyTo))
                    {
                        currentFile2.copyTo(dir1, logXML, syncJSON);
                    }
                }
            }
            logJSON.serialize(syncJSON);

            Form2 form2 = new Form2();

            form2.Show();
        }
Esempio n. 3
0
        public void overwrite(Folder dir, LogXML logXML, SyncEntryJSON syncJSON, int mode)
        {
            switch (mode)
            {
            case 1:
                File.Delete(dir.copyTo);
                logXML.addFileEntry(dir.copyTo, "удален, т.к. есть более новая версия");
                EntryJSON entry = new EntryJSON(dir.copyTo, "удален, т.к. есть более новая версия");
                syncJSON.addFileEntry(entry);
                copyTo(dir, logXML, syncJSON);
                break;

            case 2:
                File.Delete(fullPath);
                logXML.addFileEntry(fullPath, "удален, т.к. есть более новая версия");
                entry = new EntryJSON(fullPath, "удален, т.к. есть более новая версия");
                syncJSON.addFileEntry(entry);
                copyFrom(dir, logXML, syncJSON);
                break;
            }
        }
Esempio n. 4
0
 public Form2()
 {
     logXML  = new LogXML();
     logJSON = new LogJSON();
     InitializeComponent();
 }