1

I have to display image in form in my application, the image in a shared directory for every one in the server

If I attempt to read the image by:

fullImagePath = Path.Combine(@"\\serverIP\IMG_IN_server", imageFileName);
byte[] img = File.ReadAllBytes(fullImagePath);

but I get error "Access to the path is denied"

edit: can I use the user and the password to connect to avoid this problem ?

Akrem
  • 5,033
  • 8
  • 37
  • 64
  • 4
    there's nothing wrong with the code you've posted, it just sounds like the path you specified is wrong – Jason Oct 29 '11 at 15:06
  • I verified the path I correct the error but Now I got "Access to the path is denied." – Akrem Oct 29 '11 at 15:18
  • Check that your application has read access to that location. This is not necessarily the same as **you** having read access. – ChrisF Oct 29 '11 at 15:20
  • can I use the user and the password to connect to avoid this problem ? – Akrem Oct 29 '11 at 15:29
  • can access to this file from windows Explorer ? make sure this isn't security problem! – Rev Oct 30 '11 at 05:57
  • @Rev: No I can't access to this file by explorer – Akrem Oct 30 '11 at 22:22
  • Check [answer](http://stackoverflow.com/questions/1271701/reading-image-from-web-server-in-c-sharp-proxy/1272126#1272126) given to [Reading Image from Web Server in C# [proxy](http://stackoverflow.com/questions/1271701/reading-image-from-web-server-in-c-sharp-proxy/). It reads image data into – mloskot Oct 29 '11 at 15:05

1 Answers1

0

So as Result your test:

I can Say your problem is normal security configuration. In order to have access that file you need share that file with allow security permission.

Your Code is right Just go for security permission.

Rev
  • 2,269
  • 8
  • 45
  • 75