By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

access denied when trying to use the fileStream

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"JvCoach23" <ra*****@sauder.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
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

Nov 21 '05 #2

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.