当前位置: 首页>>代码示例>>C#>>正文


C# ProjectItem.Delete方法代码示例

本文整理汇总了C#中ProjectItem.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.Delete方法的具体用法?C# ProjectItem.Delete怎么用?C# ProjectItem.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectItem的用法示例。


在下文中一共展示了ProjectItem.Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteAndAdd

 private static void DeleteAndAdd(ProjectItem item, string path)
 {
     string temp = Path.GetTempFileName();
     File.Copy(path, temp, true);
     item.Delete();
     File.Copy(temp, path);
     File.Delete(temp);
 }
开发者ID:nategreenwood,项目名称:FileNesting,代码行数:8,代码来源:ManualNester.cs

示例2: UnNest

		private static void UnNest(Project parent, ProjectItem childItem)
		{
			foreach (var grandChild in childItem.ProjectItems.OfType<ProjectItem>())
			{
				UnNest(parent, grandChild);
			}

			var contentType = childItem.Properties.Item("ItemType").Value;

			var filePath = childItem.FileNames[0];
			var tempFile = Path.GetTempFileName();
			File.Copy(filePath, tempFile, true); 
			
			childItem.Delete();
			
			File.Copy(tempFile, filePath); 
			File.Delete(tempFile);
			var newItem = parent.ProjectItems.AddFromFile(filePath);
			newItem.Properties.Item("ItemType").Value = contentType;
		}
开发者ID:GitObjects,项目名称:nestin,代码行数:20,代码来源:Worker.cs

示例3: RemoveItemFromItems

        /// <summary>
        /// 移除项目中的项
        /// </summary>
        /// <param name="projectItem"></param>
        /// <param name="itemName">项名称</param>
        /// <param name="isDelete">是否删除或者移除</param>
        private bool RemoveItemFromItems(ProjectItem projectItem, string itemName, bool isDelete)
        {
            bool isRemove = false;
            ProjectItem item;
            if (projectItem.Name == itemName)
            {
                item = projectItem;
                if (isDelete)
                {
                    item.Delete();
                }
                else
                {
                    item.Remove();
                }
                isRemove = true;
            }
            else if (projectItem.ProjectItems.Count > 0)
            {
                item = FindProjectItem(projectItem, itemName);
                if (item.Name == itemName)
                {
                    if (isDelete)
                    {
                        item.Delete();
                    }
                    else
                    {
                        item.Remove();
                    }
                    isRemove = true;
                }
            }

            return isRemove;
        }
开发者ID:Allen-Zhou,项目名称:AF,代码行数:42,代码来源:ModelExtendEvent.cs

示例4: RemoveFromProject

        /// <summary>
        /// Removes the specified project item from the test project.
        /// </summary>
        /// <param name="projectItem">The project item to remove.</param>
        public static void RemoveFromProject(ProjectItem projectItem)
        {
            Assert.IsNotNull(projectItem);

            UIThreadInvoker.Invoke(new Action(() =>
            {
                int initialCount = Project.ProjectItems.Count;

                projectItem.Delete();

                Assert.AreEqual(initialCount - 1, Project.ProjectItems.Count);
            }));
        }
开发者ID:reima,项目名称:codemaid,代码行数:17,代码来源:TestEnvironment.cs

示例5: DeleteItem

        private void DeleteItem(ProjectItem projectItem, DTE vs)
        {
            string itemPath = DteHelper.BuildPath(projectItem);
            itemPath = DteHelper.GetPathFull(vs, itemPath);

            projectItem.Remove();
            projectItem.Delete();
        }
开发者ID:riseandcode,项目名称:open-wscf-2010,代码行数:8,代码来源:DeleteProjectItemsAction.cs

示例6: DeleteProjectItem

        /// <summary>
        /// Deletes the specified <paramref name="item" /> and its parent folders if they are empty.
        /// </summary>
        /// <param name="item">
        /// A Visual Studio <see cref="ProjectItem" />.
        /// </param>
        /// <remarks>
        /// This method correctly deletes empty parent folders in C# and probably
        /// Visual Basic projects which are implemented in C++ as pure COM objects.
        /// However, for Database and probably WiX projects, which are implemented
        /// as .NET COM objects, the parent collection indicates item count = 1
        /// even after its only child item is deleted. So, for new project types,
        /// this method doesn't delete empty parent folders. However, this is probably
        /// desirable for Database projects that create a predefined, empty folder
        /// structure for each schema. We may need to solve this problem in the
        /// future by recording which folders were actually created by the code
        /// generator in the log file and deleting the empty parent folders when
        /// the previously generated folders become empty.
        /// </remarks>
        private static void DeleteProjectItem(ProjectItem item)
        {
            ProjectItems parentCollection = item.Collection;

            item.Delete();

            if (parentCollection.Count == 0)
            {
                var parent = parentCollection.Parent as ProjectItem;
                if (parent != null && parent.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder)
                {
                    DeleteProjectItem(parent);
                }
            }
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:34,代码来源:OutputFileManager.cs


注:本文中的ProjectItem.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。