Server MapPath

H

Henrique Berenguel

Hello folks. How do I solve the problem below?

when my program executes the line below :

Package.WriteXml(Server.MapPath(strID[1] + ".XML"));

Ireceive the following error message:

System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\postingcenter\SGOC4.XML" is denied. at
System.IO.__Error.WinIOError(Int32 errorCode, String str) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) at System.Xml.XmlTextWriter..ctor(String
filename, Encoding encoding) at System.Data.DataSet.WriteXml(String
fileName, XmlWriteMode mode) at System.Data.DataSet.WriteXml(String
fileName) at PostingCenter.pc0001.PostMessageToEMS(DataSet Package, String
sFromModule, String sToModule) in
c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line 149 at
PostingCenter.pc0001.DispatchMessage(DataSet Package, String sFromModule,
String sToModule) in c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line
168 at PostingCenter.pc0001.sendPackage(DataSet Package, String sFromModule,
String[] sToModule) in c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line
108 --- End of inner exception stack trace ---
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException:
System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---> System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\postingcenter\SGOC4.XML" is denied. at
System.IO.__Error.WinIOError(Int32 errorCode, String str) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) at System.Xml.XmlTextWriter..ctor(String
filename, Encoding encoding) at System.Data.DataSet.WriteXml(String
fileName, XmlWriteMode mode) at System.Data.DataSet.WriteXml(String
fileName) at PostingCenter.pc0001.PostMessageToEMS(DataSet Package, String
sFromModule, String sToModule) in
c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line 149 at
PostingCenter.pc0001.DispatchMessage(DataSet Package, String sFromModule,
String sToModule) in c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line
168 at PostingCenter.pc0001.sendPackage(DataSet Package, String sFromModule,
String[] sToModule) in c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line
108 --- End of inner exception stack trace ---

Source Error:

Line 35:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.o
rg/sendPackage", RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 36: public int sendPackage(System.Data.DataSet Package, string
sFromModule, string[] sToModule) {
Line 37: object[] results = this.Invoke("sendPackage", new
object[] {
Line 38: Package,
Line 39: sFromModule,


Source File: c:\inetpub\wwwroot\sgocnet\Web
References\localhost1\Reference.cs Line: 37

Stack Trace:

[SoapException: System.Web.Services.Protocols.SoapException: Server was
unable to process request. ---> System.UnauthorizedAccessException: Access
to the path "c:\inetpub\wwwroot\postingcenter\SGOC4.XML" is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share)
at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)
at System.Data.DataSet.WriteXml(String fileName, XmlWriteMode mode)
at System.Data.DataSet.WriteXml(String fileName)
at PostingCenter.pc0001.PostMessageToEMS(DataSet Package, String
sFromModule, String sToModule) in
c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line 149
at PostingCenter.pc0001.DispatchMessage(DataSet Package, String
sFromModule, String sToModule) in
c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line 168
at PostingCenter.pc0001.sendPackage(DataSet Package, String sFromModule,
String[] sToModule) in c:\inetpub\wwwroot\postingcenter\pc0001.asmx.cs:line
108
--- End of inner exception stack trace ---]

System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClient
Message message, WebResponse response, Stream responseStream)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
sgocnet.localhost1.pc0001.sendPackage(DataSet Package, String
sFromModule, String[] sToModule) in c:\inetpub\wwwroot\sgocnet\Web
References\localhost1\Reference.cs:37
sgocnet.comOfficer.PostMessage(DataSet Package, String sFromModule,
String[] sToModule) in c:\inetpub\wwwroot\sgocnet\comofficer.cs:32
sgocnet.comOfficer.PreparePackage(DataSet Package, String sFromModule,
String[] sToModule) in c:\inetpub\wwwroot\sgocnet\comofficer.cs:24
sgocnet.co0005.SendMessageForOfficer() in
c:\inetpub\wwwroot\sgocnet\co0005.aspx.cs:294
sgocnet.co0005.btIncluir_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\sgocnet\co0005.aspx.cs:470
System.Web.UI.WebControls.Button.OnClick(EventArgs e)

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1263
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top