/// <summary> /// Copy a directory recursively to the specified non-existing directory /// </summary> /// <param name="source">Directory to copy from</param> /// <param name="target">Directory to copy to</param> public static void RecursivelyCopyDirectory(string source, string target) { // Make sure it doesn't already exist if (Directory.Exists(target)) throw new ApplicationException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.FileOrFolderAlreadyExists, CultureInfo.CurrentUICulture), target)); Directory.CreateDirectory(target); DirectoryInfo directory = new DirectoryInfo(source); // Copy files foreach (FileInfo file in directory.GetFiles()) { file.CopyTo(Path.Combine(target, file.Name)); } // Now recurse to child directories foreach (DirectoryInfo child in directory.GetDirectories()) { RecursivelyCopyDirectory(child.FullName, Path.Combine(target, child.Name)); } }
/// <summary> /// Adds a reference to this container using the selector data structure to identify it. /// </summary> /// <param name="selectorData">data describing selected component</param> /// <returns>Reference in case of a valid reference node has been created or already existed. Otherwise null</returns> public ReferenceNode AddReferenceFromSelectorData(VSCOMPONENTSELECTORDATA selectorData) { //Make sure we can edit the project file if (!this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } //Create the reference node ReferenceNode node = null; try { node = CreateReferenceNode(selectorData); } catch (ArgumentException) { // Some selector data was not valid. } //Add the reference node to the project if we have a valid reference node if (node != null) { ReferenceNode existingNode; if (!node.IsAlreadyAdded(out existingNode)) { // Try to add node.AddReference(); if (null == node.Parent) { // The reference was not added, so we can not return this item because it // is not inside the project. return(null); } } else { IVsDetermineWizardTrust wizardTrust = this.GetService(typeof(SVsDetermineWizardTrust)) as IVsDetermineWizardTrust; var isWizardRunning = 0; if (wizardTrust != null) { ErrorHandler.ThrowOnFailure(wizardTrust.IsWizardRunning(out isWizardRunning)); } // if assembly already exists in project and we are running under the wizard - do not raise error if (isWizardRunning != 0) { return(existingNode); } else { string message = string.IsNullOrEmpty(node.SimpleName) ? String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.ReferenceAlreadyExists, CultureInfo.CurrentUICulture), node.Caption, existingNode.Caption) : String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.ReferenceWithAssemblyNameAlreadyExists, CultureInfo.CurrentUICulture), node.Caption, node.SimpleName, existingNode.Caption); throw new InvalidOperationException(message); } } } return(node); }
/// <summary> /// Caption of the property grid, prints 'Reference properties' similar to C# /// </summary> /// <returns></returns> public override string GetClassName() { return(SR.GetString(SR.ReferenceProperties, CultureInfo.CurrentUICulture)); }