locked
Deleting a file or folder throws "System.UnauthorizedAccessException was caught" Exception in windows store app RRS feed

  • Question

  • Hi,

    In our windows store app, we store files in Localstate folder. When try to delete that folder or any file in that folder throws "System.UnauthorizedAccessException was caught" error.

    Even creating folder with RepalceExisting option also throws the above error.

    What is wrong in it? can anyone give solution?

    Thanks.

    Monday, March 5, 2018 5:30 PM

All replies

  • Hi PM16

    >> In our windows store app, we store files in Localstate folder.

    Could you ensure the Localstate folder is the local folder for the app? I suggest that you could take a look at the folder in the file explorer. Make sure it is not a read-only folder.

    Does the problem happen to other devices?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, March 6, 2018 2:25 AM
  • Hi Roy,

    Thank you.

    When i check the properties of this LocalState folder, it is set as "Read-only". and it all the devices too. Should i change anything from application side ?

    Tuesday, March 6, 2018 2:36 AM
  • @PM16,

    Sorry for the delay.

    This is strange. In general, the local folder could be read and write via your app.

    Could you please tell me your OS version and target version?

    Have you do something to the local folder before you tried to create a file into it?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 8, 2018 7:19 AM
  • Hi Roy,

    I found the reason for above error. I was directly using the path of those files in my application. That is why i got the "UnauthorizedAccessException". Now i read the content of that file and i use it. Now i am able to delete these files.

    Thanks.

    Friday, April 6, 2018 1:11 PM