Click here to Skip to main content
15,886,782 members
Home / Discussions / C#
   

C#

 
GeneralRe: spd Pin
Henry Minute13-Sep-09 13:25
Henry Minute13-Sep-09 13:25 
Questionis0 8583 Pin
moein.serpico13-Sep-09 9:48
moein.serpico13-Sep-09 9:48 
AnswerRe: is0 8583 Pin
Henry Minute13-Sep-09 9:57
Henry Minute13-Sep-09 9:57 
AnswerRe: is0 8583 Pin
Christian Graus13-Sep-09 13:21
protectorChristian Graus13-Sep-09 13:21 
QuestionModify file attributes... Access denied. Pin
JollyMansArt13-Sep-09 8:46
JollyMansArt13-Sep-09 8:46 
AnswerRe: Modify file attributes... Access denied. Pin
Henry Minute13-Sep-09 9:34
Henry Minute13-Sep-09 9:34 
GeneralRe: Modify file attributes... Access denied. Pin
JollyMansArt13-Sep-09 10:01
JollyMansArt13-Sep-09 10:01 
GeneralRe: Modify file attributes... Access denied. Pin
Henry Minute13-Sep-09 10:20
Henry Minute13-Sep-09 10:20 
JollyMansArt wrote:
I don't get an error in code.


In your original post you said:

it give me a access denied #5 and invalid parameter #87.


which is why I asked about errors.

Never mind.

Some of the methods of Bitmap behave in a rather thuggish manner, in that they don't always release files that they have accessed. So I would suggest that you dispose your bitmap before trying the FileAttributes part.

Something like this:
Bitmap bitmap = new Bitmap(1, 1);
//string fullPath = string.Format("{0}\\bitmap.bmp", Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
//string fullPath = string.Format("{0}", BMP_Path);
bitmap.Save(BMP_Path);
bitmap = null;        //<================================== HERE ********************************
bitmap.Dispose();     //<================================== HERE ********************************
if ((File.GetAttributes(BMP_Path) & FileAttributes.Hidden) != FileAttributes.Hidden)
{
    //Adds to the existing file attributes
    File.SetAttributes(BMP_Path, File.GetAttributes(BMP_Path) | FileAttributes.Hidden);
    //Replaces the file attributes
    File.SetAttributes(BMP_Path, File.GetAttributes(BMP_Path) & FileAttributes.Hidden);
}


I cannot guarantee that this will work, I have not tested it. It is based purely on known behaviour of Bitmap.

I do hope that you only use one of your attribute setting lines at a time, otherwise you cannot tell what is and what is not working.

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: Modify file attributes... Access denied. Pin
JollyMansArt13-Sep-09 11:38
JollyMansArt13-Sep-09 11:38 
QuestionC# for Linux Pin
DarkSorrow3813-Sep-09 7:55
DarkSorrow3813-Sep-09 7:55 
AnswerRe: C# for Linux Pin
N a v a n e e t h13-Sep-09 8:01
N a v a n e e t h13-Sep-09 8:01 
Questionimage to crystal report Pin
tanweer13-Sep-09 6:49
tanweer13-Sep-09 6:49 
AnswerRe: image to crystal report Pin
Henry Minute13-Sep-09 9:41
Henry Minute13-Sep-09 9:41 
Questioncodr to make superscript and subscripi of selected text Pin
santosh_anu13-Sep-09 4:14
santosh_anu13-Sep-09 4:14 
AnswerRe: codr to make superscript and subscripi of selected text Pin
Eddy Vluggen13-Sep-09 4:21
professionalEddy Vluggen13-Sep-09 4:21 
AnswerRe: codr to make superscript and subscripi of selected text Pin
dan!sh 13-Sep-09 4:30
professional dan!sh 13-Sep-09 4:30 
QuestionFinding class and method definitions in .cs files Pin
LeonLiber13-Sep-09 3:50
LeonLiber13-Sep-09 3:50 
AnswerRe: Finding class and method definitions in .cs files Pin
Richard MacCutchan13-Sep-09 4:18
mveRichard MacCutchan13-Sep-09 4:18 
AnswerRe: Finding class and method definitions in .cs files [modified] Pin
dan!sh 13-Sep-09 4:21
professional dan!sh 13-Sep-09 4:21 
GeneralRe: Finding class and method definitions in .cs files Pin
LeonLiber13-Sep-09 5:37
LeonLiber13-Sep-09 5:37 
GeneralRe: Finding class and method definitions in .cs files Pin
Daniel Grunwald13-Sep-09 8:03
Daniel Grunwald13-Sep-09 8:03 
GeneralRe: Finding class and method definitions in .cs files Pin
LeonLiber13-Sep-09 8:32
LeonLiber13-Sep-09 8:32 
GeneralRe: Finding class and method definitions in .cs files [modified] Pin
N a v a n e e t h13-Sep-09 8:37
N a v a n e e t h13-Sep-09 8:37 
GeneralRe: Finding class and method definitions in .cs files Pin
Daniel Grunwald13-Sep-09 8:39
Daniel Grunwald13-Sep-09 8:39 
GeneralRe: Finding class and method definitions in .cs files Pin
dan!sh 13-Sep-09 8:40
professional dan!sh 13-Sep-09 8:40 

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.