Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / June 2004

Tip: Looking for answers? Try searching our database.

Access is denied with FileStream object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin - 15 Jun 2004 16:11 GMT
Hi,

I am writing a web service which contains a function that tries to
open up a FileStream.

When I try to do this I get the following error

"Access to the path "C:\Handheld\Images\1100314670.jpg" is denied"

I can do things like CopyFile so don't know how it can be a
permissions problem.  I only seem to have a problem with FileStream.

Any thoughts???

   <WebMethod(Description:="Get image")> _
   Public Function GetImage(ByVal i_code As String) As
Xml.XmlDocument

       Try
           Dim f1 As IO.File
           If Not f1.Exists("C:\Handheld\Images\1100314670.jpg") Then
               Return Nothing
           End If
           Dim F As System.IO.FileStream = New
System.IO.FileStream("C:\Handheld\Images\1100314670.jpg",
IO.FileMode.Open)
           Dim binRead As BinaryReader = New BinaryReader(F)

           Dim objXml As Xml.XmlTextWriter = New
Xml.XmlTextWriter("C:\Handheld\Test.xml", System.Text.Encoding.UTF8)

           objXml.WriteStartDocument()

           objXml.WriteStartElement("ct", "ContactDetails",
"http://10.0.0.196/Contact")
           objXml.WriteStartElement("image")
           objXml.WriteAttributeString("logo", "1100314670.jpg")

           Dim readByte As Integer = 0
           Dim bytesToRead As Integer = 100

           Dim base64Buffer(bytesToRead) As Byte

           Do
               readByte = binRead.Read(base64Buffer, 0, bytesToRead)
               objXml.WriteBase64(base64Buffer, 0, readByte)
           Loop While (bytesToRead <= readByte)

           objXml.WriteEndElement()

           objXml.WriteEndElement()

           objXml.WriteEndDocument()

           objXml.Flush()
           objXml.Close()

           Dim xd As Xml.XmlDocument
           xd.Load("C:\Handheld\Test.xml")

           Return xd

       Catch ex As Exception
           Return Nothing
           'MsgBox("Error in SharScanService." & vbNewLine &
ex.Message)
       End Try

   End Function
Kondratyev Denis - 18 Jun 2004 21:07 GMT
Are ASP.NET work process and IIS work process (for IIS 6.0) have read
permissions for this folder?

> Hi,
>
[quoted text clipped - 9 lines]
>
> Any thoughts???
Martin - 21 Jun 2004 08:46 GMT
It was just a permissions problem.  I thought that giving sharing to
everyone would have been enough but I had to specify permission to the
ASP user.

> Are ASP.NET work process and IIS work process (for IIS 6.0) have read
> permissions for this folder?
[quoted text clipped - 12 lines]
> >
> > Any thoughts???

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.