shwaqar82
asked on
Access to the path is denied
I have the following code:
Try
webReqGateway = WebRequest.Create("http://drv.sax.softvoyage.com/cgi-bin/gateway_dest.cgi")
webReqHotel = WebRequest.Create("http://drv.sax.softvoyage.com/cgi-bin/dest_hotels.cgi")
webResGateway = webReqGateway.GetResponse
webResHotel = webReqHotel.GetResponse
strmGateway = New StreamReader(webResGateway .GetRespon seStream)
xmlGateway = New StreamWriter(Server.MapPat h("//XML/G ateway.xml "), False)
xmlHotel = New StreamWriter(Server.MapPat h("//XML/H otel.xml") , False)
'Console.WriteLine(strmGat eway.ReadL ine.ToStri ng)
xmlGateway.WriteLine(strmG ateway.Rea dToEnd)
strmHotel = New StreamReader(webResHotel.G etResponse Stream)
xmlHotel.WriteLine(strmHot el.ReadToE nd)
xmlGateway.Close()
xmlHotel.Close()
Try
'check for errors in xml and replace invalid characters if needed
docGateway = LoadXMLDoc(Server.MapPath( "//XML/Gat eway.xml") )
docHotel = LoadXMLDoc(Server.MapPath( "//XML/Hot el.xml"))
Catch ex As XmlException
lnum = ex.LineNumber
ReplaceSpecialChars(Server .MapPath(" //XML/Hote l.xml"), lnum)
docHotel = LoadXMLDoc(Server.MapPath( "//XML/Hot el.xml"))
End Try
Response.Write("Xml Created on time " & Date.Now.ToString)
Catch er As XmlException
Response.Write("Xml could not be created " & er.Message)
Catch er As HttpException
Response.Write("Xml could not be created " & er.Message)
Catch er As Exception
Response.Write("Xml could not be created " & er.Message)
End Try
When i run it. It gives me an error message which says:
Xml could not be created Access to the path 'F:\websites\local\dreamva cations\XM L\Hotel.xm l' is denied.
xmlGateway = New StreamWriter(Server.MapPat h("//Gatew ay.xml"), False)
The above line works fine and create Gateway.xml on root directory which is a network directory(F:\websites\loca l\dreamvac ations) and the web address for this is: http://192.168.0.29
Also tried the below line:
xmlGateway = New StreamWriter(Server.MapPat h("http://192.168.0.29/XML/Gateway.xml"), False)
Doesn't work. Any help please....:(
Try
webReqGateway = WebRequest.Create("http://drv.sax.softvoyage.com/cgi-bin/gateway_dest.cgi")
webReqHotel = WebRequest.Create("http://drv.sax.softvoyage.com/cgi-bin/dest_hotels.cgi")
webResGateway = webReqGateway.GetResponse
webResHotel = webReqHotel.GetResponse
strmGateway = New StreamReader(webResGateway
xmlGateway = New StreamWriter(Server.MapPat
xmlHotel = New StreamWriter(Server.MapPat
'Console.WriteLine(strmGat
xmlGateway.WriteLine(strmG
strmHotel = New StreamReader(webResHotel.G
xmlHotel.WriteLine(strmHot
xmlGateway.Close()
xmlHotel.Close()
Try
'check for errors in xml and replace invalid characters if needed
docGateway = LoadXMLDoc(Server.MapPath(
docHotel = LoadXMLDoc(Server.MapPath(
Catch ex As XmlException
lnum = ex.LineNumber
ReplaceSpecialChars(Server
docHotel = LoadXMLDoc(Server.MapPath(
End Try
Response.Write("Xml Created on time " & Date.Now.ToString)
Catch er As XmlException
Response.Write("Xml could not be created " & er.Message)
Catch er As HttpException
Response.Write("Xml could not be created " & er.Message)
Catch er As Exception
Response.Write("Xml could not be created " & er.Message)
End Try
When i run it. It gives me an error message which says:
Xml could not be created Access to the path 'F:\websites\local\dreamva
xmlGateway = New StreamWriter(Server.MapPat
The above line works fine and create Gateway.xml on root directory which is a network directory(F:\websites\loca
Also tried the below line:
xmlGateway = New StreamWriter(Server.MapPat
Doesn't work. Any help please....:(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
do i have to create user name and password for asp.net user ..how can i do that...As i unchecked anonymous access
you don't neet to, just right-click on Hotel.xml file and select Properties. Then then go to Security tab and look for something like this in the user list:
ASP.NET Machine Acount
If you find it, select it and see if it has necessary permissions to Hotel.xml file.
If you don't see it, click on Add and Type in ASPNET and click on Check Names. Then click OK. Add the necessary permissions for that user
ASP.NET Machine Acount
If you find it, select it and see if it has necessary permissions to Hotel.xml file.
If you don't see it, click on Add and Type in ASPNET and click on Check Names. Then click OK. Add the necessary permissions for that user
ASKER
well i cant get that exactly what ur saying ..but yae hotel.xml has read n write permissions. And this application pops up an authentication window once i change the web.congif and add additinal tag in it .
Please help me out :(
Please help me out :(
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think the user has an access to read n write. If not then how it can create xml files to root directory which is :
'F:\websites\local\dreamva
xmlGateway = New StreamWriter(Server.MapPat