473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

access denied when trying to use the fileStream

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
3 11729
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Carnahan | last post by:
Using .net in aspx page with following code, and get a write error on the website, but everything works fine on the development machine. ----- code ---- Dim counter As String = CType(logcount,...
1
by: Bruce W...1 | last post by:
Running Windows 2000 Server here. My ASP.NET app reads an XML file (in the virtual root on the local machine) like this just fine: DataSet ds = new DataSet();...
4
by: Brent Bigler | last post by:
The computer: W2K server, domain controller, Microsoft.Net Framework 1.1 ======================== The error message: Access to the path "c:\fanmail\newfiles" is denied .... Exception...
1
by: Microsoft News | last post by:
I have a web server sitting on computer 1, (QA1). Out on the network on my main server I have a folder with a zip file in it. All I want is for the web services that are on the web server to pick...
1
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is...
2
by: Alex Levi | last post by:
I'm tring to open a file using FileStream: dim myFile As New FileStream(myPath, FileMode.Open) It works on every file on FAT32 HDD fine. But when I try to open a several files on NTFS drive I...
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.