Created
January 17, 2017 02:18
-
-
Save ajpinedam/f8ed9eadc3c79dd10c21084928352074 to your computer and use it in GitHub Desktop.
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
| async Task GetResourceFile (string fileStorageName, string directory, string fileName) | |
| { | |
| var storageInstance = CloudStorageAccount.Parse (Settings.AzureKey); | |
| var fileClient = storageInstance.CreateCloudFileClient (); | |
| var share = fileClient.GetShareReference (fileStorageName); | |
| if (!await share.ExistsAsync ()) | |
| { | |
| return; | |
| } | |
| var root = share.GetRootDirectoryReference (); | |
| //Igual si el archivo esta directamente en el root no es necesario esto | |
| // y puedes pasar al metodo de mas abajo que busca el archivo directamente. | |
| var myFilesDirectory = root.GetDirectoryReference (directory); | |
| if (!await myFilesDirectory.ExistsAsync ()) | |
| { | |
| return; | |
| } | |
| var file = myFilesDirectory.GetFileReference (fileName); | |
| if (!await file.ExistsAsync ()) | |
| { | |
| return; | |
| } | |
| //aqui estoy haciendo esto para mostrar el contenido pero si deseas descargalo debes usar el otro metodo | |
| // await file.DownloadToFileAsync ("ruta_archivo_con_extension", System.IO.FileMode.Create); | |
| var text = await file.DownloadTextAsync (); | |
| _fileEditText.Text = text; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment