access denied when trying to use the fileStream

  • Thread starter Thread starter JvCoach23
  • Start date Start date
J

JvCoach23

I'm trying to run a

LoadAllImages(ds.Tables(0), "vcFileName", "d:\Image")

Public Shared Sub LoadAllImages(ByVal MyDataTable As DataTable, ByVal
FilePathField As String, ByVal ImageField As String)
'loop through all the rows and load the images
For Each dr As DataRow In MyDataTable.Rows
LoadImage(dr, ImageField, dr.Item(FilePathField))
Next
End Sub

Public Shared Sub LoadImage(ByVal MyDataRow As System.Data.DataRow,
ByVal FilePath As String, ByVal ImageField As String)
Dim fs As New System.IO.FileStream(FilePath, IO.FileMode.Open,
System.IO.FileAccess.Read)
Dim Image(fs.Length) As Byte
fs.Read(Image, 0, fs.Length)
fs.Close()
MyDataRow.Item(ImageField) = Image

End Sub

I get the error An unhandled exception of type
'System.UnauthorizedAccessException' occurred in mscorlib.dll

Additional information: Access to the path "d:\Image" is denied.

This is happening on the dim fs as new system.io.filestream.... line.
I am a local adminstrator to my box. I'm running vb.net 2003 and am
trying to do this in a windows form. There is info in the dataset
table that I'm passing in. Can someone help me get around this problem
please
thanks
shannon
 
Sounds like you are having framework security issues. If you want to access
files on a network drive you need to setup your program as fully trusted in
the Intranet policy area.

Chris
 
thanks for the replie. I'm not trying to access files on a network
drive though.. I'm trying to access files on my local machine.. I'm
login as as someone with Administrator privledges. Hope you have a
suggestion for this situation. Thanks

Shannon Ramirez
Vb.Net newbie
Sql Vet
 
I got it working. I was wrong in what I was passing in. I was trying
to pass in a path.. when it was looking for the datatype.


LoadAllImages(ds.Tables(0), "vcFileName", "Image")

was what I needed. Thanks

Shannon Ramirez
Vb.Net newbie
Sql Vet
 
Back
Top