I would like to read from the Drive C: to search for a file in subfolders for my file search program everything works fine when I test this program in Visual studio but when I publish the project and my program try to read from the Drive it throw the Permission exception please tell me how to solve this I have tried code on MSDN but no luck also I am not able to run file as administrator with no error. Here is my code.
try
{
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Read, Path.Text);
f2.Demand();
AddDir(Directory.GetDirectories(Path.Text));
}
catch (Exception e)
{
MessageBox.Show($"Sorry we cannot read directories from {Path} because {e.ToString()}");
Startthread.Abort();
}
Exception