I can read the text file for first time. when i try to read the same text file next time, it quit the function and return null value.
static string configData = "";
async public void readtextFile(string folder, string file)
{
StorageFolder storageFolder = await Package.Current.InstalledLocation.GetFolderAsync(folder);
StorageFile storageFile = await storageFolder.GetFileAsync(file);
configData = await FileIO.ReadTextAsync(storageFile);
}
Please suggest me, how to resolve this issue..
Thanks
SheikAbdullah
Don’t forget that
readtextFileis an asynchronous method. When you call it, it actually returns when it reaches the firstawait, so at this pointconfigDatais not set yet. You should return the value from the method, and await the method:Even if you want to store
configDatain a field, you still need toawait readtextFilebefore you read the value.