本文整理汇总了C#中System.IO.MemoryStream.ReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.MemoryStream.ReadAsync方法的具体用法?C# System.IO.MemoryStream.ReadAsync怎么用?C# System.IO.MemoryStream.ReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryStream
的用法示例。
在下文中一共展示了System.IO.MemoryStream.ReadAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunAsync
public async Task RunAsync() {
var apks = CommandRunner.Instance.GetInstalledPackagesApkInformation ( );
this.LogDebug("Initializing APK Cache");
foreach(var item in apks) {
var lvi = new ApkPackageListViewItem(item);
// cant uninstall if we dont know the package
if(string.IsNullOrEmpty(lvi.ApkInformation.Package)) {
continue;
}
string keyName = lvi.ApkInformation.DevicePath;
if(keyName.StartsWith("/")) {
keyName = keyName.Substring(1);
}
keyName = keyName.Replace("/", ".");
if(!Program.SystemIcons.ContainsKey(keyName)) {
// get apk and extract the app icon
var img = CommandRunner.Instance.GetLocalApkIconImage(item.LocalApk);
if(img == null) {
img = DroidExplorer.Resources.Images.package32;
} else {
using(System.IO.MemoryStream stream = new System.IO.MemoryStream()) {
string fileName = System.IO.Path.Combine(System.IO.Path.Combine(CommandRunner.Settings.UserDataDirectory, Cache.APK_IMAGE_CACHE), string.Format("{0}.png", keyName));
img.Save(stream, ImageFormat.Png);
stream.Position = 0;
using(System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)) {
byte[] buffer = new byte[2048];
int readBytes = 0;
while((readBytes = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0) {
await fs.WriteAsync(buffer, 0, readBytes);
}
}
}
}
//SystemImageListHost.Instance.AddFileTypeImage ( keyName, img, img );
}
}
}