Created
January 14, 2019 14:27
-
-
Save LoriBru/82b0f0ba89b8f0aa48f84c4a6e073595 to your computer and use it in GitHub Desktop.
Snippet to copy a file from embedded assets to a folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var br = new BinaryReader(Application.Context.Assets.Open(FileName))) | |
| { | |
| using (var bw = new BinaryWriter(new FileStream("/Folder/" + $"{FileName}", FileMode.Create))) | |
| { | |
| var buffer = new byte[2048]; | |
| var length = 0; | |
| while ((length = br.Read(buffer, 0, buffer.Length)) > 0) | |
| { | |
| bw.Write(buffer, 0, length); | |
| } | |
| } | |
| } | |
| new MediaScanner("/Folder/" + $"{FileName}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment