I'm storing some data in a txt file and using that as a data source to populate my combobox.
This is my Mainpage.cs code:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.LoadComboBox();
}
public async void LoadComboBox()
{
await Task.Run(() =>
{
Task.Yield();
try
{
string[] lineOfContents = File.ReadAllLines(@"C:\path\to\myData.txt");
foreach (var line in lineOfContents)
{
comboBox1.Items.Add(line);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
}
});
}
}
Error:
Access to the path "..." is denied.
I've already modified the file properties to give full permission to Network Service if that helps.
Appreciate your help.