I’m building a WPF app. I have a function to check and create a file. The issue I am encountering is, after creating the file, the next time I run the app, it throws Exception because I do not have admin privilege to read the file. How do I create the file so that even if users run the app without Administrator privilege, it can still read it?
using MadMilkman.Ini;
public static void CreateFile(string path, string iniFilePath)
{
try
{
// if the folder does not exist, create one.
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
// check if there is Settings.ini file
// if the file does not exist, create one
if (!File.Exists(iniFilePath))
{
MadMilkman.Ini.IniFile file = new();
file.Save(iniFilePath);
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
Even if I create a text file using file.writeallText(), the same thing happens.