本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}));
}
示例5: DeleteItem
private void DeleteItem(ProjectItem projectItem, DTE vs)
{
string itemPath = DteHelper.BuildPath(projectItem);
itemPath = DteHelper.GetPathFull(vs, itemPath);
projectItem.Remove();
projectItem.Delete();
}
示例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);
}
}
}