public virtual void RemoveFile(string path) { if (EnvDTEProjectUtility.DeleteProjectItem(EnvDTEProject, path)) { string folderPath = Path.GetDirectoryName(path); if (!String.IsNullOrEmpty(folderPath)) { NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_RemovedFileFromFolder, Path.GetFileName(path), folderPath); } else { NuGetProjectContext.Log(MessageLevel.Debug, Strings.Debug_RemovedFile, Path.GetFileName(path)); } } }
public void DeleteDirectory(string path, bool recursive) { // Only delete this folder if it is empty and we didn't specify that we want to recurse if (!recursive && (FileSystemUtility.GetFiles(ProjectFullPath, path, "*.*", recursive).Any() || FileSystemUtility.GetDirectories(ProjectFullPath, path).Any())) { NuGetProjectContext.Log(MessageLevel.Warning, NuGet.ProjectManagement.Strings.Warning_DirectoryNotEmpty, path); return; } // Workaround for TFS update issue. If we're bound to TFS, do not try and delete directories. if (SourceControlUtility.GetSourceControlManager(NuGetProjectContext) == null && EnvDTEProjectUtility.DeleteProjectItem(EnvDTEProject, path)) { NuGetProjectContext.Log(MessageLevel.Debug, NuGet.ProjectManagement.Strings.Debug_RemovedFolder, path); } }