C# delete folder with read-only files


















This method does not recurse through the reparse point. If the reparse point is a symbolic link to a file, the reparse point is deleted and not the target of the symbolic link. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Delete Method Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback?

Namespace: System. IO Assemblies: mscorlib. Deletes a specified directory, and optionally any subdirectories. Delete String. 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.

Upvote 0 Downvote. NoUserHere Well-known member. 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? Skydiver Staff member. 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.

Last edited: Sep 28, What is the full path of the source folder? What is the full path of the destination folder? What antivirus is currently running on the machine? Click to expand A DirectoryInfo object exposes a Attributes property that you can get and set as needed. See post 8. As I said, you should be able to set the attributes.

Learn more. C delete a folder and all files and folders within that folder Ask Question. Asked 11 years, 11 months ago. Active 1 year, 5 months ago. Viewed k times. ReadOnly; dir. Delete ; dataGridView1. RemoveAt dataGridView1. Show ex. Improve this question. Scott Weldon 8, 6 6 gold badges 47 47 silver badges 62 62 bronze badges. Jamie Jamie 2, 9 9 gold badges 26 26 silver badges 31 31 bronze badges.

Add a comment. Active Oldest Votes. Improve this answer. Tommy Carlier Tommy Carlier 7, 3 3 gold badges 23 23 silver badges 42 42 bronze badges. Read the Manual: Directory. Delete Method String, Boolean Directory.

Delete folderPath, true ;. Ali Vojdanian 1, 2 2 gold badges 27 27 silver badges 45 45 bronze badges. Morfildur Morfildur Why read the manual when it's much quicker to google it and end up here? This is so true — Corvin. What I do sometimes is ask the question and then answer it myself, to help future googlers.

StackOverflow allows you to post the question and answer simultaneously. I've started to do all my local documenation this way. How do I? Show 3 more comments.



0コメント

  • 1000 / 1000