C# 筛选P4.Net文件列表
我有一个程序,用perforce仓库中选定目录中包含的文件的详细信息填充组合框 相关代码如下所示:C# 筛选P4.Net文件列表,c#,perforce,getfiles,C#,Perforce,Getfiles,我有一个程序,用perforce仓库中选定目录中包含的文件的详细信息填充组合框 相关代码如下所示: PerforcePath dir = _ctlProductSelect.SelectedItem as PerforcePath; _ctlServicePackSelect.Items.Clear(); if (dir != null) { foreach (P4.File file in _perforce.GetFiles(null, P4.FileSpec.DepotSpec
PerforcePath dir = _ctlProductSelect.SelectedItem as PerforcePath;
_ctlServicePackSelect.Items.Clear();
if (dir != null)
{
foreach (P4.File file in _perforce.GetFiles(null, P4.FileSpec.DepotSpec(dir.Path + "/*.sp")))
{
_ctlServicePackSelect.Items.Add(new PerforcePath(file.DepotPath.Path));
}
}
问题是,这还包括标记为已删除的文件。是否有任何方法可以从
GetFiles
方法返回的列表中筛选已删除的文件?我在P4_dotNet API文档中找不到任何可能的嫌疑犯。使用P4API.NET,您可以将-e
选项添加到GetFiles
:
IList filesToFind = new List();
FileSpec fileToFind = new FileSpec(new DepotPath("//depot/..."), null, null, VersionSpec.Head);
filesToFind.Add(fileToFind);
Options o = new Options();
o.Add("-e", "");
IList filesFound = pRep.GetFiles(filesToFind, o);
我最终的工作是在foreach循环中执行此操作:
foreach (P4.File file in _perforce.GetFiles(null, P4.FileSpec.DepotSpec(dir.Path + "/*.sp")))
{
if (_perforce.GetFileMetaData(null, file)[0].HeadAction.ToString() != "MoveDelete")
_ctlServicePackSelect.Items.Add(new PerforcePath(file.DepotPath.Path));
}
在将每个文件添加到组合框之前,基本上检查其元数据。IList filesToFind=new List();
IList<FileSpec> filesToFind = new List<FileSpec>();
FileSpec fileToFind = new FileSpec(FileSpec.DepotSpec("//depot/...").DepotPath, Revision.Head);
filesToFind.Add(fileToFind);
Options o = new Options();
o.Add("-m", "changelistid");
IList<File> FilesFound = rep.GetFiles(filesToFind, o)
FileSpec fileToFind=newfilespec(FileSpec.DepotSpec(“//depot/…”).DepotPath,Revision.Head);
filesToFind.Add(fileToFind);
选项o=新选项();
o、 添加(“-m”,“changelistid”);
IList FilesFound=rep.GetFiles(filesToFind,o)
是否尝试检查文件
对象的本地路径
或客户端路径
属性以查看文件是否已删除?