Click here to Skip to main content
15,888,293 members
Home / Discussions / C#
   

C#

 
GeneralGrant permission to access the Msysobjects Pin
Daminda11-Feb-04 21:18
Daminda11-Feb-04 21:18 
GeneralRe: Grant permission to access the Msysobjects Pin
Heath Stewart12-Feb-04 3:56
protectorHeath Stewart12-Feb-04 3:56 
GeneralImage into a database Pin
bengolong11-Feb-04 20:42
bengolong11-Feb-04 20:42 
GeneralRe: Image into a database Pin
Mazdak11-Feb-04 22:43
Mazdak11-Feb-04 22:43 
GeneralDeleting read-only files Pin
pankajdaga11-Feb-04 20:42
pankajdaga11-Feb-04 20:42 
GeneralRe: Deleting read-only files Pin
Colin Angus Mackay11-Feb-04 23:15
Colin Angus Mackay11-Feb-04 23:15 
GeneralRe: Deleting read-only files Pin
pankajdaga12-Feb-04 5:49
pankajdaga12-Feb-04 5:49 
GeneralRe: Deleting read-only files Pin
Tom Larsen12-Feb-04 5:13
Tom Larsen12-Feb-04 5:13 
I think your best shot is to iterate. There really is no way to get around the fact you are manipulating a set of files when you fail. FileInfo.Attributes will have the flags of the file you point it too.

FileInfo info = new FileInfo(thepathtofile);
info.Attributes &= ~FileAttributes.ReadOnly;


It will remove the Read-Only flag from the file if it is set (and do nothing if it isn't).

Of course this insn't foolproof either. If you don't have permissions to change this on a previlaged filesystem then you'll get an SecurityException toggling the flag.

In general terms, you just have to deal with the fact permissions aren't set correctly. Maybe the correct course of action for when attempting a Directory.Delete where you have Read-Only files is to catch the exception and abort. Altert the user and don't attempt to fix it on your own. There might be a good reason why a Read-Only file is in a directory.
GeneralRe: Deleting read-only files Pin
pankajdaga12-Feb-04 5:48
pankajdaga12-Feb-04 5:48 
GeneralHelp required......... Pin
shkhan11-Feb-04 20:16
shkhan11-Feb-04 20:16 
GeneralRe: Help required......... Pin
John Kuhn11-Feb-04 20:39
John Kuhn11-Feb-04 20:39 
GeneralDeep copy Hashtable Pin
RickardB11-Feb-04 20:15
RickardB11-Feb-04 20:15 
GeneralRe: Deep copy Hashtable Pin
Heath Stewart12-Feb-04 3:43
protectorHeath Stewart12-Feb-04 3:43 
GeneralRe: Deep copy Hashtable Pin
RickardB12-Feb-04 19:06
RickardB12-Feb-04 19:06 
GeneralRe: Deep copy Hashtable Pin
Heath Stewart13-Feb-04 3:31
protectorHeath Stewart13-Feb-04 3:31 
GeneralListing the tables of MS Access (Error is This) Pin
Daminda11-Feb-04 17:14
Daminda11-Feb-04 17:14 
GeneralRe: Listing the tables of MS Access (Error is This) Pin
krisp11-Feb-04 19:34
krisp11-Feb-04 19:34 
GeneralWhile we're on the subject of language constructs Pin
Tom Clement11-Feb-04 16:27
professionalTom Clement11-Feb-04 16:27 
GeneralRe: While we're on the subject of language constructs Pin
krisp11-Feb-04 16:47
krisp11-Feb-04 16:47 
GeneralRe: While we're on the subject of language constructs Pin
Kentamanos11-Feb-04 16:54
Kentamanos11-Feb-04 16:54 
GeneralRe: While we're on the subject of language constructs Pin
Tom Clement11-Feb-04 17:07
professionalTom Clement11-Feb-04 17:07 
GeneralRe: While we're on the subject of language constructs Pin
Werdna13-Feb-04 12:23
Werdna13-Feb-04 12:23 
GeneralStoring RichText data in Access Database Field Pin
bjulien11-Feb-04 15:51
bjulien11-Feb-04 15:51 
GeneralRe: Storing RichText data in Access Database Field Pin
John Kuhn11-Feb-04 16:29
John Kuhn11-Feb-04 16:29 
GeneralRe: Storing RichText data in Access Database Field Pin
Heath Stewart12-Feb-04 3:35
protectorHeath Stewart12-Feb-04 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.