There are times when you want to copy the files to isolated storage in your Windows Phone 8 App which you can do it easily using C#.
Below is a sample code snippet that demonstrates the copying of file to isolated storage in Windows Phone 8 using C#?
How to Save File to Isolated Storage in Windows Phone 8?
private static void SaveFileToIsolatedStorage(Uri fileUri,string _fileName) { var AppIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); var FileName = AppIsolatedStorage.CreateFile(_fileName); var FileData = Application.GetResourceStream(fileUri); byte[] bytes = new byte[4096]; int Count; while ((Count = FileData.Stream.Read(bytes, 0, 4096)) > 0) { FileName.Write(bytes, 0, Count); } FileName.Close(); }
Calling the function
Uri songUri = new Uri("test.mp3", UriKind.RelativeOrAbsolute); SaveFileToIsolatedStorage(songUri, "test.mp3");
Note: make sure that test.mp3’s build action is set to “Content” and the “Copy to Output Directory” is set to “Copy Always”.
Thank you! from Argentina. I was using IsoStoreSpy in win 8 but in win 10 its not working. This helped me a lot. Thanks again.
Thanks for the feedback 🙂