Using filestream to display a read only jpg file

  • Thread starter Thread starter AndyNakamura
  • Start date Start date
A

AndyNakamura

Guest
I have a db application that stores paths to image files in a directory in the hard drive.

The file is copied to this directory when the user wants to insert an image, along with the path being save in the db.

If the original file has the read only attribute set, then the code fails at:

Dim fs As New System.IO.FileStream(strImgMain, IO.FileMode.Open)

strImageMain is simply the path and filename.

With a
System.UnauthorizedAccessException: Access to the path C:\IMAGES\bdde0b6a-ea01-4cae-841c-fef145b5244f.tif' is denied.

Is there any way to deal with this other than removing the read only attribute manually before copying the file.
I guess if I try to remove the attribute programmatically, I'm likely to get the same denial.

Thanks

Andy

Continue reading...
 
Back
Top