public object GetImage(Uri imageLocation) { using (var stream = _resourceDataProvider.GetDataStream(imageLocation)) { if (stream == null) { return(null); } var img = new BitmapImage(); img.SetSource(stream); return(img); } }
private SoundEffectInstance LoadSound(string path) { using (var stream = _resourceDataProvider.GetDataStream(path)) { SoundEffect sound = SoundEffect.FromStream(stream); return(sound.CreateInstance()); } }
private async Task <string> CopyFile(string srcFile, string dstFile) { var file = await FileSystem.Current.LocalStorage.CreateFileAsync(dstFile, CreationCollisionOption.ReplaceExisting); using (var dst = await file.OpenAsync(FileAccess.ReadAndWrite)) { using (var src = _resourceDataProvider.GetDataStream(srcFile)) { var buffer = new byte[4096]; int bytes = -1; while ((bytes = src.Read(buffer, 0, buffer.Length)) > 0) { dst.Write(buffer, 0, bytes); } } } return(file.Path); }