I have a uwp and i need to get text from a txt file saved on the internet to string I have a problem with download the file and get the text to string
Here\'s my co
I find an answer to my question
I've to download the txt file to my local storage and after that i read them from my local
Here's the code that i used to download the file to my local folder
var uriBing = new Uri(@"https://your/abc.txt");
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.CreateFileAsync("status.txt", CreationCollisionOption.ReplaceExisting);
var cli = new HttpClient();
Byte[] bytes = await cli.GetByteArrayAsync(uriBing);
IBuffer buffer = bytes.AsBuffer(); await Windows.Storage.FileIO.WriteBufferAsync(sampleFile, buffer);
Thanks for helping hope this will help anyone look for something like this
var url = "http://example.com/abc.txt";
var textFromFile = (new WebClient()).DownloadString(url);