本文整理汇总了C#中System.IO.Compression.ZipArchive.GetOrCreateEntry方法的典型用法代码示例。如果您正苦于以下问题:C# ZipArchive.GetOrCreateEntry方法的具体用法?C# ZipArchive.GetOrCreateEntry怎么用?C# ZipArchive.GetOrCreateEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Compression.ZipArchive
的用法示例。
在下文中一共展示了ZipArchive.GetOrCreateEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateYnabSettingsYroot
private async Task<JObject> UpdateYnabSettingsYroot(ZipArchive userArchive)
{
var dropboxResult = await this.GetClient()
.GetAsync("https://content.dropboxapi.com/1/files/auto/.ynabSettings.yroot");
if (dropboxResult.StatusCode != HttpStatusCode.OK)
return null;
var content = await dropboxResult.Content.ReadAsByteArrayAsync();
var entry = userArchive.GetOrCreateEntry(".ynabSettings.yroot");
using (var stream = entry.Open())
{
await stream.WriteAsync(content, 0, content.Length);
}
return JObject.Parse(Encoding.UTF8.GetString(content));
}
示例2: ReadCursorForBudget
private async Task<string> ReadCursorForBudget(ZipArchive userArchive, string budgetPath)
{
var cursorFilePath = Path.Combine(budgetPath, "DropboxDeltaCursor.txt");
using (var stream = userArchive.GetOrCreateEntry(cursorFilePath).Open())
using (var reader = new StreamReader(stream, Encoding.UTF8))
{
return await reader.ReadToEndAsync();
}
}
示例3: UpdateCursorForBudget
private async Task UpdateCursorForBudget(ZipArchive userArchive, string budgetPath, string cursor)
{
var cursorFilePath = Path.Combine(budgetPath, "DropboxDeltaCursor.txt");
using (var stream = userArchive.GetOrCreateEntry(cursorFilePath).Open())
using (var writer = new StreamWriter(stream, Encoding.UTF8))
{
await writer.WriteAsync(cursor);
}
}