storagefile

Cannot implicitly convert type IAsyncOperation<StorageFile> to StorageFile

做~自己de王妃 提交于 2021-02-08 19:45:59
问题 What the hell is wrong with my code? private void BrowseButton_Click(object sender, RoutedEventArgs e) { FileOpenPicker FilePicker = new FileOpenPicker(); FilePicker.FileTypeFilter.Add(".exe"); FilePicker.ViewMode = PickerViewMode.List; FilePicker.SuggestedStartLocation = PickerLocationId.Desktop; // IF I PUT AWAIT HERE V I GET ANOTHER ERROR¹ StorageFile file = FilePicker.PickSingleFileAsync(); if (file != null) { AppPath.Text = file.Name; } else { AppPath.Text = ""; } } It gives me this

The component cannot be found. (Exception from HRESULT: 0x88982F50)

左心房为你撑大大i 提交于 2020-03-21 11:37:46
问题 The above exception occurs at line await bitmapImage.SetSourceAsync(fileStream); whenever I tried to retrieve image from local file. This is the method I'm using for storing and retrieving the image file. public async Task<BitmapImage> RetrieveImageFromFile(String fileName) { try { StorageFile localFile = await _storageFolder.GetFileAsync(fileName + "Img"); BitmapImage bitmapImage = new BitmapImage(); using (IRandomAccessStream fileStream = await localFile.OpenAsync(FileAccessMode.Read)) {

Convert Image to Base64 string

杀马特。学长 韩版系。学妹 提交于 2020-01-25 01:29:06
问题 I am trying to convert an Image file to Base64 string in UWP with StorageFile Here's the method I have: public async Task<string> ToBase64String(StorageFile file) { var stream = await file.OpenAsync(FileAccessMode.Read); var decoder = await BitmapDecoder.CreateAsync(stream); var pixels = await decoder.GetPixelDataAsync(); var bytes = pixels.DetachPixelData(); return await ToBase64(bytes, (uint)decoder.PixelWidth, (uint)decoder.PixelHeight, decoder.DpiX, decoder.DpiY); } and ToBase64 goes like

FileInformationFactory GetVirtualizedItemsVector() does not update the file path when folder name is changed in UWP

ⅰ亾dé卋堺 提交于 2020-01-25 00:13:10
问题 I am using for a UWP app the FileInformationFactory to retrieve Virtualized vector of Items, which can be either a folder or a file information. I query the following folder structure on my desktop: F0/F1/File1.png Hence, I have a folder F0 , which includes a folder F1 and the latter has a file File1.png . I set the IndexerOption.DoNotUseIndexer (code below), and that is at the origin of the issue. I need to use this option such that I can scan non-indexed USB drives. The result of the query

Call file from another method

青春壹個敷衍的年華 提交于 2020-01-17 08:27:38
问题 Newbie question here. I have this file picker: public async void PickImage() { FileOpenPicker ImagePicker = new FileOpenPicker(); ... StorageFile file = await ImagePicker.PickSingleFileAsync(); // ... } And I want to use the file set by this image picker in another method. Something like this: private async void CreateButton_Click(object sender, RoutedEventArgs e) { ... the one from PickImage() v StorageFile copyImage = await file.CopyAsync(DateTimeFolder, "image", NameCollisionOption

GridView looses track of items in a NotIndexed location and many do not get displayed anymore

半城伤御伤魂 提交于 2020-01-16 08:53:14
问题 I am using for a UWP app the FileInformationFactory to retrieve a Virtualized vector of files object which are cast to a FileInformation and displayed in a GridView . I want to query a folder on a SD card plugged onto my laptop and compare the virtualization of the GridView when this folder is in a FullyIndexed location, such as my Desktop. This SD card has a folder containing 15,000 text files of zero bytes. Each file is named x.txt where x runs from 1-15000 (this can be generated in a

Launching PDF reader on windows phone 8

偶尔善良 提交于 2020-01-11 11:18:02
问题 I'm trying to launch pdf reader with the code below but it does not work. Can somebody help me? private async Task<StorageFile> WriteData(string fileName, byte[] data) { StorageFolder folder = ApplicationData.Current.LocalFolder; StorageFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); using (Stream s = await file.OpenStreamForWriteAsync()) { await s.WriteAsync(data, 0, data.Length); s.Close(); } return file; } private async Task<bool> OpenPdf

uwp StorageFile adding a custom property

三世轮回 提交于 2020-01-05 11:06:32
问题 In my uwp app I am getting Video files with KnownFolders.VideoLibrary . I am able to PreFetch videoProperties of the file and also some other properties. Now I actually want to tag the video files with some string data, and save that data so I can check that later on. For example I want to add them to Liked Videos so can I add a custom property on the storagefile which will remain saved every time I run the app. This will let me check whether a specific storagefile is liked or not. Currently

C# W10 UWP BackgroundTask StorageFile

左心房为你撑大大i 提交于 2019-12-25 14:05:08
问题 I'm trying to set an image to lockscreen or wallpaper in my C# W10 UWP app in a BackgroundTask ... I can do this just fine in normal execution, but when I put the same code into a BackgroundTask , the code hangs at StorageFile.CreateStreamedFileFromUriAsync . // See if file exists already, if so, use it, else download it StorageFile file = null; try { file = await ApplicationData.Current.LocalFolder.GetFileAsync(name); } catch (FileNotFoundException) { if (file == null) { Debug.WriteLine(

WinRT StorageFile DisplayName strange behavior

淺唱寂寞╮ 提交于 2019-12-11 01:04:10
问题 In a Windows 8 app on Windows 8.1 I use the DisplayName property of StorageFile to get a 'friendly' file name. In the majority of the cases the result is the name of the file without the extension but sometimes the result is the name of the file with the extension. This second case seems to happen when I create a new folder and immediately create a file in it. Does anyone know if there is a consistent rule for this behavior? Thanks! 回答1: It is a strange but You can create extension method