System.UnauthorizedAccessException

I am getting the below error when i am trying read a file on the desktop. I am able to read the file on any other location. Can you tell me why i am getting this error.

System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings\XXXXX\Desktop\kk\XXXXX86.JPG' is denied.


Here is the statement i am using to read the file.

System.IO.FileStream stream = new System.IO.FileStream(file,
                                                                            FileMode.Open,
                                                                            FileAccess.Read);
k_kosarajuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aki4uCommented:
Do you have read-only attribute unchecked?
Are you/asp.net included in Security tab and what permissions you have set?
k_kosarajuAuthor Commented:
yes read only is unchecked.

where i need to set the security permissions.

I launched my application online. When i try to read the file which is not on desktop i am getting this error.

System.IO.IOException: The device is not ready.

if i try to read the file on desktop i am getting this error

System.IO.DirectoryNotFoundException:
aki4uCommented:
System.IO.IOException: The device is not ready...is probably because you are trying to access C drive on the server
System.IO.DirectoryNotFoundException ...error is self explanatory

security permissions:
file properties->security tab

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aki4uCommented:
solution provided
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.