public virtual void AddLinkMap(string ASource, string ATarget) { FileSystemWatcher LWatcher = (FileSystemWatcher)Application["LinkTableWatcher"]; lock (LWatcher) { LWatcher.EnableRaisingEvents = false; try { Customization.LinkTable LTable = (Customization.LinkTable)Application["LinkTable"]; // Add the link LTable.Add(ASource, ATarget); // Save the link map table string LLinkTableFileName = (string)Application["ApplicationPath"] + '\\' + CLinkTableFileName; using (FileStream LStream = new FileStream(LLinkTableFileName, FileMode.Create, FileAccess.Write, FileShare.None)) LTable.Write(LStream); } finally { LWatcher.EnableRaisingEvents = true; } } }
// Links /// <summary> Refreshes the Linkmap Table from the file. </summary> public void UpdateLinkTable() { try { Customization.LinkTable LLinkTable = (Customization.LinkTable)Application["LinkTable"]; if (LLinkTable == null) { LLinkTable = new Customization.LinkTable(); Application.Add("LinkTable", LLinkTable); } else { LLinkTable.Clear(); } string LLinkTableFileName = (string)Application["ApplicationPath"] + '\\' + CLinkTableFileName; if (File.Exists(LLinkTableFileName)) { using (FileStream LStream = new FileStream(LLinkTableFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) LLinkTable.Read(LStream); } } catch (Exception LException) { LogException(LException); } }