How to get thumbnail of Video Storage File in Windows phone app

StorageFile class provides us with the method called GetThumbnailAsync with the help of which we can retrieve the thumbnail of a storage file in Windows phone app.   Important Note: This method works only on the Storage Files that are stored in public directory of the phone. It doesn’t work on the files that are […]

Read More

How to copy one StorageFile into another StorageFile in Windows phone app using C#

StorageFile class provides a method called CopyAsync to copy the contents of one file into another. The code for the above is as following     Note: In the given code above we replace the contents of filetoReplace by filetoCopy.   If you want to copy the file to a given StorageFolder you can use the […]

Read More

How to get the file size of Storage File in Windows phone app

StorageFile class provides different methods with the help of which we can retrieve the file size of a give StorageFile.   In the given function below we retrieve the file size of a given StorageFile using GetBasicPropertiesAsync() method. This method returns the basic properties of the given Storagefile in form of class object from which […]

Read More

Convert StorageFile to a BitmapImage in Universal Windows Apps

We have already seen how to convert a WritableBitmap to a StorageFile in Universal Windows apps. A StorageFile can be converted to a BitmapImage using the following function. public class ImageUtils { public static async Task<BitmapImage> StorageFileToBitmapImage(StorageFile savedStorageFile) { using (IRandomAccessStream fileStream = await savedStorageFile.OpenAsync(Windows.Storage.FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.DecodePixelHeight = 100; bitmapImage.DecodePixelWidth […]

Read More

Converting WritableBitmap to StorageFile in Universal Windows Apps

WriteableBitmap is quite useful when an app requires image processing. It provides a BitmapSource, that can be written and manipulated. Ultimately that bitmap source is supplied to an image control of a Windows Store app. We are going to save the WritableBitmap to a StorageFile in our app. For image encoding WinRT offers the BitmapEncoder […]

Read More

Convert Storage File to Byte Array in Universal Windows apps

This async function converts a storage file to a byte array. public static async Task<byte[]> GetBytesAsync(StorageFile file) { byte[] fileBytes = null; if (file == null) return null; using (var stream = await file.OpenReadAsync()) { fileBytes = new byte[stream.Size]; using (var reader = new DataReader(stream)) { await reader.LoadAsync((uint)stream.Size); reader.ReadBytes(fileBytes); } } return fileBytes; } It […]

Read More