0

I am trying to read and write from drive C: in my program but every time I select the drive it throws the FileIOPermission exception.Please tell me how to make application to access the protected path without exception.Also the solution works fine when debug in Visual Studio. Here is exception preview.

Preview

Screen Shot

Code`

 public void Start()
    {


        try
            {

            if ( !Directory.EnumerateFileSystemEntries(Path.Text).Any()==true)
                {


                MessageBox.Show("Directory is Empty");


                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Sorry cannot read directory because {ex.ToString()}");

            Startthread.Abort();


        }
  }
TAHA SULTAN TEMURI
  • 4,031
  • 2
  • 40
  • 66
  • You dont have access to the C:\ drive content. You could try to use administrator account with max priviledges, and try to set the app manifest file to require administrator's right when run. Read here: https://stackoverflow.com/questions/4383288/how-can-i-embed-an-application-manifest-into-an-application-using-vs2008 – pitersmx Jun 05 '17 at 07:14
  • I published the application as clickonce so run as admin not support by clickonce. – TAHA SULTAN TEMURI Jun 05 '17 at 07:24
  • Please add the manifest file as I said - and set its priviledges to requireAdministrator – pitersmx Jun 05 '17 at 07:25
  • As I told you I have tried add mainfest file but RequireAdmininstrator not support by ClickOnce. – TAHA SULTAN TEMURI Jun 05 '17 at 07:26
  • Ok sorry, got that. – pitersmx Jun 05 '17 at 07:26

0 Answers0