private void SaveAssembly() { AssemblyDefinition ad = TreeViewHandler.GetCurrentAssembly(); if (ad == null) { SimpleMessage.ShowInfo("Cannot determine current assembly."); return; } string initDir = null; if (!String.IsNullOrEmpty(_lastSaveDir)) { initDir = _lastSaveDir; } else { initDir = SourceDir; } string initFileName = _lastSaveFileName; string origFileName = Path.GetFileName(ad.MainModule.FullyQualifiedName); if (String.IsNullOrEmpty(initFileName) || !Path.GetFileNameWithoutExtension(initFileName).StartsWith(Path.GetFileNameWithoutExtension(origFileName))) { initFileName = origFileName; } string file = SimpleDialog.OpenFile("Save As", Consts.FilterAssemblyFile, Path.GetExtension(initFileName), false, initDir, initFileName); if (!String.IsNullOrEmpty(file)) { if (File.Exists(file)) { File.Delete(file); } string adPath = Path.GetDirectoryName(ad.MainModule.FullyQualifiedName); bool resolveDirAdded = Host.AddAssemblyResolveDir(adPath); try { ad.Write(file); } finally { if (resolveDirAdded) { Host.RemoveAssemblyResolveDir(adPath); } } _lastSaveDir = Path.GetDirectoryName(file); _lastSaveFileName = Path.GetFileName(file); //Config.LastSaveDir = _lastSaveDir; SimpleMessage.ShowInfo(String.Format("Assembly saved to {0}", file)); if (file.Equals(initFileName, StringComparison.OrdinalIgnoreCase)) { TreeViewHandler.ClearRenamedObjects(); } } }