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?
 
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
0
 
aki4uCommented:
Do you have read-only attribute unchecked?
Are you/asp.net included in Security tab and what permissions you have set?
0
 
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:
0
 
aki4uCommented:
solution provided
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.