本文整理汇总了C#中System.Item.DownloadFile方法的典型用法代码示例。如果您正苦于以下问题:C# Item.DownloadFile方法的具体用法?C# Item.DownloadFile怎么用?C# Item.DownloadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.DownloadFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataBlob
private BlobCommand GetDataBlob(Item item)
{
var bytes = new byte[item.ContentLength];
BlobCommand blob = null;
try
{
var str = item.DownloadFile();
str.Read(bytes, 0, bytes.Length);
str.Close();
var id = _MarkID++;
blob = BlobCommand.BuildBlob(bytes, id);
}
catch (Exception ex)
{
Console.Error.WriteLine();
Console.Error.WriteLine("Warning: Unable to fetch file '{0}'{1}{2}", item.ServerItem, Environment.NewLine, ex);
Console.Error.WriteLine();
}
return blob;
}
示例2: GetStreamFromItem
private Stream GetStreamFromItem(Item item)
{
var stream = item.DownloadFile();
if (!item.ServerItem.EndsWith(".refresh"))
return stream;
string path = new StreamReader(stream).ReadToEnd().TrimEnd('\r', '\n');
return new FileStream(path, FileMode.Open);
}
示例3: Download
private byte[] Download(Item item1)
{
using (var stream = item1.DownloadFile())
{
using (var memStream = new MemoryStream())
{
stream.CopyTo(memStream);
return memStream.ToArray();
}
}
}
示例4: ViewFile
public void ViewFile(Item theItem)
{
if (theItem != null && string.IsNullOrEmpty(theItem.ServerItem))
return;
var filename = Path.Combine(Path.GetTempPath(), Path.GetFileName(theItem.ServerItem));
try
{
theItem.DownloadFile(filename);
Process.Start(filename);
}
finally
{
File.Delete(filename);
}
}
示例5: SearchInFileContent
private static List<string> SearchInFileContent(Item file)
{
// results contains the file path and all ocurrences
List<string> results = new List<string>();
// ocurrences contains the lines where
List<string> occurrences = new List<string>();
StreamReader streamReader = new StreamReader(file.DownloadFile(), Encoding.Default);
string line = streamReader.ReadLine();
int lineIndex = 0;
while (!streamReader.EndOfStream)
{
if (searchPatterns.Any(item => line.IndexOf(item, StringComparison.OrdinalIgnoreCase) > 0))
{
occurrences.Add(string.Format("Line {0}: {1}", lineIndex, line.Trim()));
}
line = streamReader.ReadLine();
lineIndex++;
}
if (occurrences.Count > 0)
{
results.Add(file.ServerItem);
results.AddRange(occurrences.Select(item => string.Format("\t{0}", item)).ToList());
}
return results;
}
示例6: GetDataBlob
private BlobCommand GetDataBlob(Item item)
{
var bytes = new byte[item.ContentLength];
var str = item.DownloadFile();
str.Read(bytes, 0, bytes.Length);
str.Close();
var id = _MarkID++;
var blob = BlobCommand.BuildBlob(bytes, id);
return blob;
}
示例7: GetTfsFile
private static string GetTfsFile(Item file)
{
string result;
if (_downloadedItems.TryGetValue(file.ItemId, out result))
{
return result;
}
else
{
result = System.IO.Path.GetTempFileName();
file.DownloadFile(result);
return result;
}
}
示例8: GetPackageDependenciesFromRepositoriesConfig
private IEnumerable<PackageDependency> GetPackageDependenciesFromRepositoriesConfig(TeamProject teamProject, Item repository)
{
List<PackageDependency> repositoryDependencies = new List<PackageDependency>();
Stream repoFileStream = repository.DownloadFile();
XDocument repoXml = XDocument.Load(repoFileStream);
IEnumerable<string> relativePackageConfigPaths = configInterpreter.GetRelativePackagesConfigPathsFromRepositoriesConfig(repoXml);
string repositoriesConfigServerPath = repository.ServerItem;
int repositoriesConfigLength = repositoriesConfigFileName.Length;
string packageConfigFolderServerPath = repositoriesConfigServerPath.Remove(repositoriesConfigServerPath.Length - repositoriesConfigLength, repositoriesConfigLength);
foreach (string packageConfigPathRelativeToRepositoriesConfig in relativePackageConfigPaths)
{
// navigate to the folder server path for the repositories.config file
string repositoryNodeServerItem = tfsServerPathTranslator.GetServerPath(packageConfigFolderServerPath, packageConfigPathRelativeToRepositoriesConfig);
Item packageConfig = teamProject.VersionControlServer.GetItem(repositoryNodeServerItem);
if (packageConfig != null)
{
Stream packagesConfigStream = packageConfig.DownloadFile();
XDocument packagesConfigXml = XDocument.Load(packagesConfigStream);
IEnumerable<PackageDependency> packageDependencies = configInterpreter.GetPackageDependenciesFromPackagesConfig(packagesConfigXml);
foreach (PackageDependency packageDependency in packageDependencies)
{
if (repositoryDependencies.Where(dp => dp.Id == packageDependency.Id && dp.VersionSpec == packageDependency.VersionSpec).FirstOrDefault() == null)
repositoryDependencies.Add(packageDependency);
}
}
}
return repositoryDependencies;
}