Answered read only folder

Status
Not open for further replies.

aronmatthew

Member
Joined
Aug 5, 2019
Messages
19
Programming Experience
Beginner
im having some problems when accessing a folder that spontaneously switches to read only after each time i change the properties of the folder by hand. this is throwing an exception each time i try to change the contents of the folder in my code. i have tried to search google and all the code i found is useless in my program. there must be a way to handle the exception.
 
If you're asking how to avoid the issue in the first place then that's not a programming issue. If the folder is read-only then of course trying to write to it is an issue. Whether it's expected behaviour or not, what happens when you perform an action manually through the OS has nothing to do with programming. If you're asking how to catch the exception that is thrown then I would assume that that would be the same way that you catch any other exception. If you don't know how to implement exception handling in C# then you should do some research on exception handling in C# and try to implement what you learn. If you do know how implement exception handling but what you wrote didn't work then you need to show us exactly what you did and explain exactly what happened, i.e. what exception was thrown and where.
 
What is your application doing to part of the file system that causes an error when a user changes folder permissions?

What type of application is this?

As par your comments regarding the folder changing to readonly, is a normal response from the file system. In-fact, it's not readonly, is partially readonly, because you have likely restricted access to a folders permission attributes. Had you not restricted access to one of the permissions, it wouldn't set itself to partially readonly, because it would likely have full permissions unless the user running on the OS is not an admin...
Normal : Screenshot
Results in : Screenshot

If this is what is happening, then this means your application is throwing an exception because it likely can't access files in that folder. Again, my question is; what does your application do that you need to have control over a given folder from your app?
 
Looking at our OP's old thread last year where it looks like he was working on a character build tool for a game, I'm guessing that now, a year later, he's moved on to having the character build tool actually trying to modify some game files. I wouldn't be surprised if the game as an anti-cheat system, and it's first line of defense is to keep making some of its folders read-only when it detects that the permissions have been changed.
 
the folder changes to read only after i uncheck the box. i built a simple app to choose a random file and copy it into another folder. the exception is thrown when trying to delete the file in the copy folder. because for some odd reason the folder is read only. i guess my question is how to check the the properties of the folder then set to read.
 
Last edited:
What is the full path of the source folder? What is the full path of the destination folder?
What method are you using to copy/move the file between folders?
What antivirus is currently running on the machine?
 
i guess my question is how to check the the properties of the folder then set to read.
For future reference, don't guess what your question is in post #5. Have a clear idea of what the question is before you post and then post it clearly. We only know what you tell us so you have to express yourself clearly. If you make us guess, there's every chance that we'll guess wrong, if we bother trying at all.
 
the exception is thrown when trying to delete the file in the copy folder. because for some odd reason the folder is read only.

I'm a curious cat, and would like to know what reason your application needs to copy random files from one location to another?

Regarding your exception, we will need the following :
  • What is the directory you are copying the files from
  • What is the directory you are copying the files too
  • What is the code you are using to copy the files to the destination folder
  • Is your application running with higher privileges
Once we get more details from you, it should be easier to help you.
 
See post #8. As I said, you should be able to set the attributes.

Please take time to answer post #6 and/or post #9. By answering those questions we'll be better able to help you.
 
I don't mean to badger you, but if you answered the previous questions you were asked, you would have likely received a satisfying answer to solve your problem already.
 
oh i see all of the sudden there it is..
System.IO.DirectoryInfo directoryInfo = new DirectoryInfo(textBox2.Text);
DirectorySecurity ds= directoryInfo.GetAccessControl();
directoryInfo.Attributes = FileAttributes.Normal;

"is it all some type of breeding machine where they hide the resources"
-me
 
If you resolved your issue, remember to mark your thread resolved from the top right corner.

It is also a sign of politeness and good manners to answer someone's questions when they take time to write them out.

Specifically this :
I'm a curious cat, and would like to know what reason your application needs to copy random files from one location to another?
 
oh i see all of the sudden there it is..
System.IO.DirectoryInfo directoryInfo = new DirectoryInfo(textBox2.Text);
DirectorySecurity ds= directoryInfo.GetAccessControl();
directoryInfo.Attributes = FileAttributes.Normal;

"is it all some type of breeding machine where they hide the resources"
-me
and then all of the sudden it throws the exception again
 
Status
Not open for further replies.
Back
Top Bottom