read xml in webservice

vincentnl

Active member
Joined
Mar 29, 2003
Messages
40
Location
Netherlands
I am programming a webservice. The client application needs a dataset, so the webservice needs to create and fill the dataset.

The dataset comes from en xml file. When creating a filestream in the webservice an error occurs. The file is not accessible.

System.UnauthorizedAccessException: Access to the path "C:\Inetpub\wwwroot\EetlijstWebService\eten.xml" is denied.


Code:
        Dim sPath As String
go down another level because mappath of server does not end at root
        sAppPath = Me.Server.MapPath("EetlijstWebService") + "\..\"
        sPath = sAppPath + sFilename
         Create the FileStream to write with.
        Dim myFileStream As New System.IO.FileStream(sPath, System.IO.FileMode.Create)
         Create an XmlTextWriter with the fileStream.
        Dim myXmlWriter As New System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode)
         Write to the file with the WriteXml method.
        ds.WriteXml(myXmlWriter)
        myXmlWriter.Close()

How can i fix it, I locate the file using c:\... for filestream does noet accept URI or URL.

Or is my IIS configured wrong?
 
I read that in another post, and it is very likely.

Since I was reading XML to make a dataset, I did some more research, and found the XMLDataDocument. Perfect for what I want. No hassle, just go from xml-file to typed dataset in 2 lines of code (6 including streamer).

This class gets access to the file ?!? While the other did not?

Well losing its relevancy, but still puzzling.

(have to say, I am new to this)
 
Yeesh. I should read things more carefully in the future. :)

Code:
Dim myFileStream As New System.IO.FileStream(sPath, System.IO.FileMode.Create)

System.IO.FileMode.Create will attempt to create a file. Thus, if the file already exists, youll run into trouble. :)

Sorry I didnt notice this before. Glad to hear you found your way out of it on your own.

.steve
 
Back
Top