access denied when trying to use the fileStream

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JvCoach23

    access denied when trying to use the fileStream

    I'm trying to run a

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

    Public Shared Sub LoadAllImages(B yVal 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.Row s
    LoadImage(dr, ImageField, dr.Item(FilePat hField))
    Next
    End Sub

    Public Shared Sub LoadImage(ByVal MyDataRow As System.Data.Dat aRow,
    ByVal FilePath As String, ByVal ImageField As String)
    Dim fs As New System.IO.FileS tream(FilePath, IO.FileMode.Ope n,
    System.IO.FileA ccess.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.Unautho rizedAccessExce ption' 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.files tream.... 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

  • Chris, Master of All Things Insignificant

    #2
    Re: access denied when trying to use the fileStream

    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" <ramirez@sauder .com> wrote in message
    news:1109258187 .231069.37850@f 14g2000cwb.goog legroups.com...[color=blue]
    > I'm trying to run a
    >
    > LoadAllImages(d s.Tables(0), "vcFileName ", "d:\Image")
    >
    > Public Shared Sub LoadAllImages(B yVal 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.Row s
    > LoadImage(dr, ImageField, dr.Item(FilePat hField))
    > Next
    > End Sub
    >
    > Public Shared Sub LoadImage(ByVal MyDataRow As System.Data.Dat aRow,
    > ByVal FilePath As String, ByVal ImageField As String)
    > Dim fs As New System.IO.FileS tream(FilePath, IO.FileMode.Ope n,
    > System.IO.FileA ccess.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.Unautho rizedAccessExce ption' 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.files tream.... 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
    >[/color]


    Comment

    • Shannon Ramirez

      #3
      Re: access denied when trying to use the fileStream

      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!

      Comment

      • Shannon Ramirez

        #4
        Re: access denied when trying to use the fileStream

        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(d s.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!

        Comment

        Working...