本文整理汇总了C#中Project.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Project.Remove方法的具体用法?C# Project.Remove怎么用?C# Project.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameFile
public static bool RenameFile(Project Project, string file, string NewFileName)
{
var absPath = Project.ToAbsoluteFileName(file);
var newFilePath =Path.Combine(Project.BaseDirectory, Path.GetDirectoryName(NewFileName),Util.PurifyFileName(Path.GetFileName(NewFileName)));
var ret = Util.MoveFile(absPath, newFilePath);
if (ret)
{
Project.Remove(file);
Project.Add(newFilePath);
Project.Save();
foreach (var e in Instance.Editors)
if (e.AbsoluteFilePath == absPath)
{
e.AbsoluteFilePath = newFilePath;
e.Reload();
}
}
return ret;
}
示例2: ExcludeDirectoryFromProject
public static bool ExcludeDirectoryFromProject(Project prj, string RelativePath)
{
if (prj == null || string.IsNullOrEmpty(RelativePath))
return false;
/*
* - Delete all subdirectory references
* - Delete all files that are inside of these directories
*/
var affectedFiles = (from f in prj.Files
where Path.GetDirectoryName(f.FileName).Contains(RelativePath)
select prj.ToAbsoluteFileName(f.FileName)).ToArray();
foreach (var ed in Instance.Editors.Where(e => affectedFiles.Contains(e.AbsoluteFilePath)))
ed.Close();
foreach (var s in prj.SubDirectories.Where(d => d == RelativePath || d.Contains(RelativePath)).ToArray())
prj.SubDirectories.Remove(s);
foreach (var s in affectedFiles)
prj.Remove(s);
prj.Save();
Instance.UpdateGUI();
return true;
}
示例3: ExludeFileFromProject
public static bool ExludeFileFromProject(Project Project, string file)
{
var absFile = Project.ToAbsoluteFileName(file);
// Close (all) editor(s) that represent our file
foreach (var ed in Instance.Editors.Where(e => e.AbsoluteFilePath == absFile).ToArray())
if (!ed.Close())
return false;
var r = Project.Remove(file);
if (r)
{
Project.Save();
Instance.MainWindow.RefreshProjectExplorer();
}
return r;
}
示例4: MoveFile
public static bool MoveFile(Project Project, string FileName, Project TargetProject, string NewDirectory)
{
/*
* - Copy file
* - Delete old physically
* - Delete old one from project
*/
Instance.CanUpdateGUI = false;
if (CopyFile(Project, FileName, TargetProject, NewDirectory) &&
Project.Remove(FileName))
{
var oldDir_rel = Path.GetDirectoryName(Project.ToRelativeFileName(FileName));
foreach(var ed in IDEManager.Instance.Editors)
if (ed.AbsoluteFilePath == Project.ToAbsoluteFileName(FileName))
{
ed.FileName = TargetProject.ToAbsoluteFileName(Path.Combine(NewDirectory, Path.GetFileName(FileName)));
}
try
{
File.Delete(Project.ToAbsoluteFileName(FileName));
}
catch (Exception ex)
{
IDELogger.Log(ex);
}
// If directory empty, keep it managed by the project
if (!Project.SubDirectories.Contains(oldDir_rel) && !string.IsNullOrEmpty(oldDir_rel))
Project.SubDirectories.Add(oldDir_rel);
Project.Save();
}
Instance.CanUpdateGUI = true;
Instance.UpdateGUI();
return false;
}