private void butValidate_Click(object sender, EventArgs e) { if (!PrefC.UsingAtoZfolder) { MsgBox.Show(this, "Not using AtoZ folders, so UpdateFiles folder does not exist."); return; } string folderUpdate = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles"); Version currentVersion = new Version(Application.ProductVersion); //identify the ideal situation where everything is already in place and no copy is needed. if (Directory.Exists(folderUpdate)) { string filePath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt"); if (File.Exists(filePath)) { string fileText = File.ReadAllText(filePath); if (fileText == currentVersion.ToString(3)) { if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "According to the information in UpdateFiles\\Manifest.txt, the UpdateFiles folder is current. Recopy anyway?")) { return; } } } } Cursor = Cursors.WaitCursor; if (!PrefL.CopyFromHereToUpdateFiles(currentVersion)) { Cursor = Cursors.Default; return; } Cursor = Cursors.Default; MsgBox.Show(this, "Recopied."); }
private void butRecopy_Click(object sender, EventArgs e) { Version versionCurrent = new Version(Application.ProductVersion); string folderUpdate = ""; if (PrefC.AtoZfolderUsed) { folderUpdate = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles"); } else //db { folderUpdate = ODFileUtils.CombinePaths(Path.GetTempPath(), "UpdateFiles"); if (Directory.Exists(folderUpdate)) { Directory.Delete(folderUpdate, true); } DocumentMisc docmisc = DocumentMiscs.GetUpdateFilesZip(); if (docmisc != null) { byte[] rawBytes = Convert.FromBase64String(docmisc.RawBase64); using (ZipFile unzipped = ZipFile.Read(rawBytes)) { unzipped.ExtractAll(folderUpdate); } } } //identify the ideal situation where everything is already in place and no copy is needed. if (Directory.Exists(folderUpdate)) { string filePath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt"); if (File.Exists(filePath)) { string fileText = File.ReadAllText(filePath); if (fileText == versionCurrent.ToString(3)) { if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "According to the information in UpdateFiles\\Manifest.txt, the UpdateFiles folder is current. Recopy anyway?")) { return; } } } } Cursor = Cursors.WaitCursor; if (!PrefL.CopyFromHereToUpdateFiles(versionCurrent)) { Cursor = Cursors.Default; return; } Cursor = Cursors.Default; MsgBox.Show(this, "Recopied."); }
private void butRecopy_Click(object sender, EventArgs e) { Version versionCurrent = new Version(Application.ProductVersion); string folderUpdate = ODFileUtils.CombinePaths(PrefC.GetTempFolderPath(), "UpdateFiles"); if (Directory.Exists(folderUpdate)) { try { Directory.Delete(folderUpdate, true); } catch { MsgBox.Show(this, "Recopy failed. Please run as administrator then try again."); return; } } Cursor = Cursors.WaitCursor; if (!PrefL.CopyFromHereToUpdateFiles(versionCurrent, false, true, true, this)) { Cursor = Cursors.Default; return; } Cursor = Cursors.Default; MsgBox.Show(this, "Recopied."); }