public static T FromBSON <T>(this string filename, bool root_is_array = false) { using (var fo = File.OpenRead(filename)) using (var br = new BsonDataReader(fo, readRootValueAsArray: root_is_array, DateTimeKind.Local)) { var serializer = JsonSerializer.Create(new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); return(serializer.Deserialize <T>(br)); } }
private async Task InstallSteamWorkshopItems() { //var currentLib = ""; SteamGame currentSteamGame = null; StoreHandler.Instance.SteamHandler.Games.Where(g => g.Game == GameInfo.Game).Do(s => currentSteamGame = (SteamGame)s); /*SteamHandler.Instance.InstallFolders.Where(f => f.Contains(currentSteamGame.InstallDir)).Do(s => currentLib = s); * * var downloadFolder = Path.Combine(currentLib, "workshop", "downloads", currentSteamGame.AppId.ToString()); * var contentFolder = Path.Combine(currentLib, "workshop", "content", currentSteamGame.AppId.ToString()); */ if (!ModList.Directives.Any(s => s is SteamMeta)) { return; } var result = await Utils.Log(new YesNoIntervention( "The ModList you are installing requires Steam Workshop items to exist. " + "You can check the Workshop Items in the manifest of this ModList. Wabbajack can start Steam for you " + "and download the Items automatically. Do you want to proceed with this step?", "Download Steam Workshop Items?")).Task; if (result != ConfirmationIntervention.Choice.Continue) { return; } await ModList.Directives.OfType <SteamMeta>() .PMap(Queue, item => { Status("Extracting Steam meta file to temp folder"); var path = Path.Combine(DownloadFolder, $"steamWorkshopItem_{item.ItemID}.meta"); if (!File.Exists(path)) { File.WriteAllBytes(path, LoadBytesFromPath(item.SourceDataID)); } Status("Downloading Steam Workshop Item through steam cmd"); var p = new Process { StartInfo = new ProcessStartInfo { FileName = Path.Combine(StoreHandler.Instance.SteamHandler.SteamPath, "steam.exe"), CreateNoWindow = true, Arguments = $"console +workshop_download_item {currentSteamGame.ID} {currentSteamGame.ID}" } }; p.Start(); }); }
public static void SaveObject(string filename, object obj) { // Make sure the path exists string pathname = Path.GetDirectoryName(filename); Directory.CreateDirectory(pathname); using (FileStream fs = File.OpenWrite(filename)) { SaveObject(fs, obj); } }
/// <summary> /// Load WebSearcher Preferences: the set of search engines (websites) which should be listed. /// /// When any mandatory web searchers are specified through the <code>mandatory_web_searchers</code> /// argument, then these will be OR-combined with the set stored as preferences. /// </summary> /// <param name="mandatory_web_searchers">May be NULL or a set of required web searchers; these will be /// added to the returned set, next to the preferences set.</param> /// <returns>A set of websearcher identifiers.</returns> public HashSet <string> LoadPreferences(HashSet <string> mandatory_web_searchers = null) { HashSet <string> preferences = new HashSet <string>(); // mix in the required set: if (null != mandatory_web_searchers) { foreach (string line in mandatory_web_searchers) { preferences.Add(line.ToUpper()); } } #if DEBUG // Are we looking at this dialog in the Visual Studio Designer? bool load_from_file = !Utilities.Misc.Runtime.IsRunningInVisualStudioDesigner; #else const bool load_from_file = true; #endif // If they have a preferences file if (load_from_file && File.Exists(PREFERENCES_FILENAME)) { using (StreamReader sr = new StreamReader(PREFERENCES_FILENAME)) { while (true) { string line = sr.ReadLine(); if (null == line) { break; } preferences.Add(line.ToUpper()); } } // We always want Google Scholar!! preferences.Add(WebSearchers.SCHOLAR_KEY); return(preferences); } // If they have no preferences file, then return the default Logging.Info("Returning default WebSearcher preferences because no preferences have been saved."); foreach (string line in GetDefaultPreferences()) { preferences.Add(line.ToUpper()); } return(preferences); }
public void Build(string outputName) { RegenFolderRecords(); if (File.Exists(outputName)) { File.Delete(outputName); } using (var fs = File.OpenWrite(outputName)) using (var wtr = new BinaryWriter(fs)) { wtr.Write(_fileId); wtr.Write(_version); wtr.Write(_offset); wtr.Write(_archiveFlags); var folders = FolderNames.ToList(); wtr.Write((uint)folders.Count); wtr.Write((uint)_files.Count); wtr.Write((uint)_folders.Select(f => f._nameBytes.Count() - 1).Sum()); // totalFolderNameLength var s = _files.Select(f => f._pathBytes.Count()).Sum(); _totalFileNameLength = (uint)_files.Select(f => f._nameBytes.Count()).Sum(); wtr.Write(_totalFileNameLength); // totalFileNameLength wtr.Write(_fileFlags); foreach (var folder in _folders) { folder.WriteFolderRecord(wtr); } foreach (var folder in _folders) { if (HasFolderNames) { wtr.Write(folder._nameBytes); } foreach (var file in folder._files) { file.WriteFileRecord(wtr); } } foreach (var file in _files) { wtr.Write(file._nameBytes); } foreach (var file in _files) { file.WriteData(wtr); } } }
private void LoadWord_LOCK(WordInWordIndex wiwi) { // If the word is already loaded, nothing to do... if (wiwi.IsLoaded) { return; } try { string filename = Filename_GangList(wiwi.WordId); using (FileStream fs = File.OpenRead(filename)) { { bool gang_has_corrupted_word_counts = false; List <WordEntry> word_entrys = Serializer.Deserialize <List <WordEntry> >(fs); int gang_start = GangStart(wiwi.WordId); for (int i = 0; i < word_entrys.Count; ++i) { if (0 != String.Compare(word_in_word_indexes[gang_start + i].Word, word_entrys[i].Word)) { throw new Exception("The ordering of the word index is corrupt: words don't match"); } if (null != word_in_word_indexes[gang_start + i].DocumentIds) { Logging.Warn("The ordering of the word index is corrupt: document_ids should be null"); } WordInWordIndex wiwi_just_loaded = word_in_word_indexes[gang_start + i]; bool corruption_detected = wiwi_just_loaded.SetDocumentIds(word_entrys[i].DocumentIds, word_entrys[i].DocumentIdsCount); if (corruption_detected) { gang_has_corrupted_word_counts = true; } } if (gang_has_corrupted_word_counts) { Logging.Warn("The ordering of a word index in the gang is corrupt: doc counts don't match (the user probably exited before the gang was saved...)"); } } } } catch (Exception ex) { Logging.Error(ex, "There was a problem loading the word document list for word {0}:{1}. Assuming it was empty.", wiwi.WordId, wiwi.Word); bool set_result = wiwi.SetDocumentIds(new List <int>(), new List <int>()); } }
public static void ToBSON <T>(this T obj, string filename) { using (var fo = File.OpenWrite(filename)) using (var br = new BsonDataWriter(fo)) { fo.SetLength(0); var serializer = JsonSerializer.Create(new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); serializer.Serialize(br, obj); } }
public SQLiteUpgrade_LibraryDB(string base_path) { this.base_path = base_path; library_path = Path.GetFullPath(Path.Combine(base_path, @"Qiqqa.library")); // Copy a library into place... if (!File.Exists(library_path)) { Logging.Warn("Library db does not exist so copying the template to {0}", library_path); string library_template_path = Path.GetFullPath(Path.Combine(StartupDirectoryForQiqqa, @"DocumentLibrary/Library.Template.s3db")); File.Copy(library_template_path, library_path); } }
public SQLiteUpgrade_LibraryDB(string base_path) { this.base_path = base_path; library_path = LibraryDB.GetLibraryDBPath(base_path); // Copy a library into place... if (!File.Exists(library_path)) { Logging.Warn("Library db does not exist so copying the template to {0}", library_path); string library_template_path = LibraryDB.GetLibraryDBTemplatePath(); File.Copy(library_template_path, library_path); } }
public IntranetLibraryDB(string base_path) { this.base_path = base_path; library_path = IntranetLibraryTools.GetLibraryMetadataPath(base_path); // Copy a library into place... if (!File.Exists(library_path)) { Logging.Warn("Intranet Library metadata db does not exist so copying the template to {0}", library_path); string library_metadata_template_path = Path.GetFullPath(Path.Combine(ConfigurationManager.Instance.StartupDirectoryForQiqqa, @"DocumentLibrary/IntranetLibraryStuff/IntranetLibrary.Metadata.Template.s3db")); File.Copy(library_metadata_template_path, library_path); } }
private static List <string> GetRecentEndnoteDatabases() { List <string> databases = new List <string>(); // Go through all the recent Endnote databases try { using (RegistryKey key_software = Registry.CurrentUser.OpenSubKey("Software", false)) { if (null != key_software) { using (RegistryKey key_isi = key_software.OpenSubKey("ISI ResearchSoft", false)) { if (null != key_isi) { using (RegistryKey key_endnote = key_isi.OpenSubKey("EndNote", false)) { if (null != key_endnote) { using (RegistryKey key_recent_libraries = key_endnote.OpenSubKey("Recent Libraries", false)) { if (null != key_recent_libraries) { foreach (string value_name in key_recent_libraries.GetValueNames()) { string filename = key_recent_libraries.GetValue(value_name) as string; if (!String.IsNullOrEmpty(filename)) { if (File.Exists(filename)) { databases.Add(filename); } } } } } } } } } } } } catch (Exception ex) { Logging.Error(ex, "There was a problem getting the recent Endnote databases."); } return(databases); }
public async Task TestUpdating() { var profile = utils.AddProfile(); var mod = utils.AddMod(); var unchanged = utils.AddModFile(mod, @"Data\scripts\unchanged.pex", 10); var deleted = utils.AddModFile(mod, @"Data\scripts\deleted.pex", 10); var modified = utils.AddModFile(mod, @"Data\scripts\modified.pex", 10); utils.Configure(); utils.AddManualDownload( new Dictionary <string, byte[]> { { "/baz/unchanged.pex", File.ReadAllBytes(unchanged) }, { "/baz/deleted.pex", File.ReadAllBytes(deleted) }, { "/baz/modified.pex", File.ReadAllBytes(modified) }, }); await CompileAndInstall(profile); utils.VerifyInstalledFile(mod, @"Data\scripts\unchanged.pex"); utils.VerifyInstalledFile(mod, @"Data\scripts\deleted.pex"); utils.VerifyInstalledFile(mod, @"Data\scripts\modified.pex"); var unchanged_path = utils.PathOfInstalledFile(mod, @"Data\scripts\unchanged.pex"); var deleted_path = utils.PathOfInstalledFile(mod, @"Data\scripts\deleted.pex"); var modified_path = utils.PathOfInstalledFile(mod, @"Data\scripts\modified.pex"); var extra_path = utils.PathOfInstalledFile(mod, @"something_i_made.foo"); File.WriteAllText(extra_path, "bleh"); var unchanged_modified = File.GetLastWriteTime(unchanged_path); var modified_modified = File.GetLastWriteTime(modified_path); File.WriteAllText(modified_path, "random data"); File.Delete(deleted_path); Assert.IsTrue(File.Exists(extra_path)); await CompileAndInstall(profile); utils.VerifyInstalledFile(mod, @"Data\scripts\unchanged.pex"); utils.VerifyInstalledFile(mod, @"Data\scripts\deleted.pex"); utils.VerifyInstalledFile(mod, @"Data\scripts\modified.pex"); Assert.AreEqual(unchanged_modified, File.GetLastWriteTime(unchanged_path)); Assert.AreNotEqual(modified_modified, File.GetLastWriteTime(modified_path)); Assert.IsFalse(File.Exists(extra_path)); }
public override async void RemoveLibraryAsync(bool withFiles) { try { if (withFiles) { DeleteFilesAsync(); } List.Libraries.Remove(this); if (Type != LibraryType.Steam) { return; } await Functions.Steam.CloseSteamAsync().ConfigureAwait(true); // Make a KeyValue reader var keyValReader = new Framework.KeyValue(); // Read vdf file keyValReader.ReadFileAsText(Global.Steam.VdfFilePath); // Remove old library keyValReader["Software"]["Valve"]["Steam"].Children.RemoveAll(x => x.Value == FullPath); var i = 1; foreach (var key in keyValReader["Software"]["Valve"]["Steam"].Children.FindAll(x => x.Name.Contains("BaseInstallFolder"))) { key.Name = $"BaseInstallFolder_{i}"; i++; } // Update libraryFolders.vdf file with changes keyValReader.SaveToFile(Global.Steam.VdfFilePath, false); // Since this file started to interrupt us? // No need to bother with it since config.vdf is the real deal, just remove it and Steam client will handle with some magic. if (File.Exists(Path.Combine(Properties.Settings.Default.steamInstallationPath, "steamapps", "libraryfolders.vdf"))) { File.Delete(Path.Combine(Properties.Settings.Default.steamInstallationPath, "steamapps", "libraryfolders.vdf")); } Functions.Steam.RestartSteamAsync(); } catch (Exception ex) { Logger.Fatal(ex); } }
private void LoadKnownWebLibraries(string filename, bool only_load_those_libraries_which_are_actually_present) { Logging.Info("+Loading known Web Libraries"); try { if (File.Exists(filename)) { KnownWebLibrariesFile known_web_libraries_file = SerializeFile.ProtoLoad <KnownWebLibrariesFile>(filename); if (null != known_web_libraries_file.web_library_details) { foreach (WebLibraryDetail new_web_library_detail in known_web_libraries_file.web_library_details) { Logging.Info("We have known details for library '{0}' ({1})", new_web_library_detail.Title, new_web_library_detail.Id); if (!new_web_library_detail.IsPurged) { // Intranet libraries had their readonly flag set on the user's current premium status... if (new_web_library_detail.IsIntranetLibrary || new_web_library_detail.IsLocalGuestLibrary || new_web_library_detail.IsWebLibrary || new_web_library_detail.IsBundleLibrary) { new_web_library_detail.IsReadOnly = false; } string libdir_path = Library.GetLibraryBasePathForId(new_web_library_detail.Id); string libfile_path = Path.GetFullPath(Path.Combine(libdir_path, @"Qiqqa.library")); if (File.Exists(libfile_path) || !only_load_those_libraries_which_are_actually_present) { UpdateKnownWebLibrary(new_web_library_detail); } else { Logging.Info("Not loading library {0} with Id {1} as it does not exist on disk.", new_web_library_detail.Title, new_web_library_detail.Id); } } else { Logging.Info("Not loading purged library {0} with id {1}", new_web_library_detail.Title, new_web_library_detail.Id); } } } } } catch (Exception ex) { Logging.Error(ex, "There was a problem loading the known Web Libraries from config file {0}", filename); } Logging.Info("-Loading known Web Libraries"); }
private void ReadMasterList() { Logging.Info("+ReadMasterList"); Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start(); lock (locker) { l1_clk.LockPerfTimerStop(); try { using (FileStream fs = File.OpenRead(GetFilename_MasterList())) { Headers headers = Serializer.Deserialize <Headers>(fs); // First the documents { foreach (var header in headers.documents) { fingerprint_to_document_ids[header.Fingerprint] = header.DocumentId; document_id_to_fingerprints[header.DocumentId] = header.Fingerprint; } } // Then the words { foreach (var header in headers.words) { WordInWordIndex wiwi = new WordInWordIndex(header.Word, header.WordId, header.DocCount); // Sanity check that they are in the right order if (wiwi.WordId != word_in_word_indexes.Count) { throw new Exception("The ordering of the word index is corrupt"); } // Add to our maps word_in_word_indexes.Add(wiwi); word_in_word_index_lookups[wiwi.Word] = wiwi; } } } } catch (Exception ex) { Logging.Warn(ex, "Unable to load index master list, so starting from scratch"); } } Logging.Info("-ReadMasterList"); }
public void ClearOCRText() { Logging.Info("Clearing OCR for document " + document_fingerprint); // Delete the OCR files for (int page = 1; page <= PageCount; ++page) { // First the SINGLE file { string filename = pdf_render_file_layer.MakeFilename_TextSingle(page); if (File.Exists(filename)) { try { File.Delete(filename); } catch (Exception ex) { Logging.Error(ex, "There was a problem while trying to delete the OCR file " + filename); } } } // Then the MULTI file { string filename = pdf_render_file_layer.MakeFilename_TextGroup(page); if (File.Exists(filename)) { try { File.Delete(filename); } catch (Exception ex) { Logging.Error(ex, "There was a problem while trying to delete the OCR file " + filename); } } } } // Clear out the old texts //Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start(); lock (texts_lock) { //l1_clk.LockPerfTimerStop(); texts.Clear(); } }
public static void RestoreDesktop() { try { // Get the remembrances if (File.Exists(Filename)) { string[] restore_settings = File.ReadAllLines(Filename); foreach (string restore_setting in restore_settings) { try { if (restore_setting.StartsWith("PDF_LIBRARY")) { string[] parts = restore_setting.Split(','); string library_id = parts[1]; Library library = WebLibraryManager.Instance.GetLibrary(library_id); MainWindowServiceDispatcher.Instance.OpenLibrary(library); } else if (restore_setting.StartsWith("PDF_DOCUMENT")) { string[] parts = restore_setting.Split(','); string library_id = parts[1]; string document_fingerprint = parts[2]; Library library = WebLibraryManager.Instance.GetLibrary(library_id); PDFDocument pdf_document = library.GetDocumentByFingerprint(document_fingerprint); if (null == pdf_document) { Logging.Warn("RestoreDesktop: Cannot find document anymore for fingerprint {0}", document_fingerprint); } else { MainWindowServiceDispatcher.Instance.OpenDocument(pdf_document); } } } catch (Exception ex) { Logging.Warn(ex, "There was a problem restoring desktop with state {0}", restore_setting); } } } } catch (Exception ex) { Logging.Error(ex, "There was a problem restoring the saved desktop state."); } }
public static void Delete(string filename) { try { if (File.Exists(filename)) { File.Delete(filename); } } catch (Exception ex) { Logging.Warn(ex, "There was a problem deleting file {0}", filename); } }
public static void ToCERAS <T>(this T obj, string filename, ref SerializerConfig config) { var ceras = new CerasSerializer(config); byte[] buffer = null; ceras.Serialize(obj, ref buffer); using (var m1 = new MemoryStream(buffer)) using (var m2 = new MemoryStream()) { BZip2.Compress(m1, m2, false, 9); m2.Seek(0, SeekOrigin.Begin); File.WriteAllBytes(filename, m2.ToArray()); } }
public static string FileHash(this string file) { var hash = new xxHashConfig(); hash.HashSizeInBits = 64; hash.Seed = 0x42; using (var fs = File.OpenRead(file)) { var config = new xxHashConfig(); config.HashSizeInBits = 64; var value = xxHashFactory.Instance.Create(config).ComputeHash(fs); return(value.AsBase64String()); } }
/// <summary> /// MurMur3 hashes the file pointed to by this string /// </summary> /// <param name="file"></param> /// <returns></returns> public static string FileSHA256(this string file) { var sha = new SHA256Managed(); using (var o = new CryptoStream(Stream.Null, sha, CryptoStreamMode.Write)) { using (var i = File.OpenRead(file)) { i.CopyToWithStatus(new FileInfo(file).Length, o, $"Hashing {Path.GetFileName(file)}"); } } return(sha.Hash.ToBase64()); }
// Delete file to RecycleBin, i.e. ensure file is recoverable after delete, if user desires such. public static void DeleteToRecycleBin(string filename) { try { if (File.Exists(filename)) { Recycle.DeleteFileOperation(filename); } } catch (Exception ex) { Logging.Warn(ex, "There was a problem deleting file {0} to the Recycle Bin.", filename); } }
/// <summary> /// Saves this instance to file. /// </summary> /// <param name="path">The file path to save to.</param> /// <param name="asBinary">If set to <c>true</c>, saves this instance as binary.</param> public void SaveToFile(string path, bool asBinary) { try { using (var f = File.Create(path)) { SaveToStream(f, asBinary); } } catch (Exception ex) { logger.Fatal(ex); } }
private string SaveToRTF() { FlowDocument flow_document = ObjDocumentViewer.Document; TextRange text_range = new TextRange(flow_document.ContentStart, flow_document.ContentEnd); string filename = TempFile.GenerateTempFilename("rtf"); using (FileStream fs = File.OpenWrite(filename)) { text_range.Save(fs, DataFormats.Rtf); } return(filename); }
public override ApprovalException Approve(string approvedPath, string receivedPath) { if (!File.Exists(approvedPath)) { //return new ApprovalMissingException(receivedPath, approvedPath); // Auto-approve BEFORE BeyondCompare gets invoked: generate the approved file on the spot. File.Copy(receivedPath, approvedPath, overwrite: true); return(null); } return(base.Approve(approvedPath, receivedPath)); }
internal static void BuildReport(WebLibraryDetail web_library_detail, List <PDFDocument> pdf_documents) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); FeatureTrackingManager.Instance.UseFeature(Features.Library_LinkedDocsAnnotationReport); StringBuilder sb_o2o = new StringBuilder(); StringBuilder sb_o2m = new StringBuilder(); foreach (var pdf_document in pdf_documents) { var citations = pdf_document.PDFDocumentCitationManager.GetLinkedDocuments(); if (null == citations || 0 == citations.Count) { continue; } // o2m { sb_o2m.AppendFormat("{0}", pdf_document.Fingerprint); sb_o2m.AppendFormat(","); foreach (var citation in citations) { sb_o2m.AppendFormat("{0}", citation.fingerprint_outbound); sb_o2m.AppendFormat(","); } sb_o2m.AppendLine(); } // o2o { foreach (var citation in citations) { sb_o2o.AppendFormat("{0}", pdf_document.Fingerprint); sb_o2o.AppendFormat(","); sb_o2o.AppendFormat("{0}", citation.fingerprint_inbound); sb_o2o.AppendLine(); } } } string filename_o2o = Path.GetTempFileName() + ".o2o.txt"; string filename_o2m = Path.GetTempFileName() + ".o2m.txt"; File.WriteAllText(filename_o2o, sb_o2o.ToString()); File.WriteAllText(filename_o2m, sb_o2m.ToString()); Process.Start(filename_o2o); Process.Start(filename_o2m); }
private void BackupFile(string file) { var path = Path.Combine(this._basePath, "BannerLordLauncher Backups"); try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch (Exception e) { this.Log().Error(e); return; } if (!File.Exists(file)) { return; } var ext = Path.GetExtension(file); var i = 0; var newFile = Path.ChangeExtension(file, $"{ext}.{i:D3}"); Debug.Assert(newFile != null, nameof(newFile) + " != null"); newFile = Path.Combine(path, Path.GetFileName(newFile)); while (File.Exists(newFile)) { i++; newFile = Path.ChangeExtension(file, $"{ext}.{i:D3}"); Debug.Assert(newFile != null, nameof(newFile) + " != null"); newFile = Path.Combine(path, Path.GetFileName(newFile)); } if (i > 999) { return; } try { Debug.Assert(file != null, nameof(file) + " != null"); File.Move(file, newFile); } catch (Exception e) { this.Log().Error(e); } }
/// <summary> /// Runs the Validation of a Modlist /// </summary> /// <param name="opts"></param> /// <returns> /// <para> /// <c>-1</c> bad Input /// <c>0</c> valid modlist /// <c>1</c> broken modlist /// </para> /// </returns> protected override async Task <int> Run() { if (!File.Exists(Input)) { Console.WriteLine($"The file {Input} does not exist!"); return(-1); } if (!Input.EndsWith(Consts.ModListExtension)) { Console.WriteLine($"The file {Input} does not end with {Consts.ModListExtension}!"); return(-1); } ModList modlist; try { modlist = AInstaller.LoadFromFile(Input); } catch (Exception e) { Console.WriteLine($"Error while loading the Modlist!\n{e}"); return(1); } if (modlist == null) { Console.WriteLine($"The Modlist could not be loaded!"); return(1); } var queue = new WorkQueue(); try { ValidateModlist.RunValidation(queue, modlist).RunSynchronously(); } catch (Exception e) { Console.WriteLine($"Error during Validation!\n{e}"); return(1); } Console.WriteLine("The Modlist passed the Validation"); return(0); }
public static bool MoveSafelyWithOverwriting(string source, string target) { if (File.Exists(source)) { if (File.Exists(target)) { File.Delete(target); } File.Move(source, target); return(true); } return(false); }
private static void IUnderstand(object obj) { try { string[] matching_files = Directory.GetFiles(ConfigurationManager.Instance.BaseDirectoryForQiqqa, PREAMBLE_FILENAME + @"*", SearchOption.TopDirectoryOnly); foreach (string filename in matching_files) { File.Delete(filename); } } catch (Exception ex) { Logging.Error(ex, "There was a problem tidying up checking for Dropbox."); } }