-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
I am trying to save the logo as a file
RandomAccessStreamReference stream = app.AppInfo.DisplayInfo.GetLogo(new Size(64, 64));
IAsyncOperation<IRandomAccessStreamWithContentType> streamOperation = stream.OpenReadAsync();
I get an error on the second line: Object reference not set to an instance of an object.
The full code
string appPackageName = notif.AppInfo.Id;
string appDisplayName = notif.AppInfo.DisplayInfo.DisplayName;
string Path = (Directory.GetCurrentDirectory() + "\\assets").Replace("\\\\", "\\");
string Filename = Path + "\\" + appPackageName + ".png";
if(!Directory.Exists(Path)){
Directory.CreateDirectory(Path);
}
if (!File.Exists(Filename)) {
RandomAccessStreamReference stream = notif.AppInfo.DisplayInfo.GetLogo(new Size(128, 128));
IAsyncOperation<IRandomAccessStreamWithContentType> streamOperation = stream.OpenReadAsync();
Task<IRandomAccessStreamWithContentType> streamTask = streamOperation.AsTask();
streamTask.Wait();
IRandomAccessStreamWithContentType content = streamTask.Result;
FileStream TheFile = File.Create(Filename);
content.AsStream().Seek(0, SeekOrigin.Begin);
content.AsStream().CopyTo(TheFile);
TheFile.Dispose();
}
Metadata
Metadata
Assignees
Labels
No labels