How to find a file path

Posted by Thiru under ASP.NET on 10/20/2011 | Points: 10 | Views : 2543 | Status : [Member] | Replies : 3
Hi Friends,

I like to find an xml file path. (Before answering please refer the solution exp. image attachment)

Its an 3Tier application
as in the main project i have an xml file named: Events.xml
i need to save xml string to this events.xml from my datalayer

note: Inside this main project i have created two new projects for business layer and data layer.
so, from this data layer project i need to save xml string to Events.xml file which is located in my main project.

I have attached the solution explorer image here with.
There you can find Event.xml file and datalayer.vb file
i need to save xmlstring from datalayer.vb file to Event.xml file
Currently i am using the full file path as:
xmldoc.Save("D:\TestProjects\SampleInvoiceWebApp\sampleinvoicewebapp\sampleinvoicewebapp\Events.xml")

But if we upload this project in server won't work - so, need to have a solution in this regard.
Expecting your valuable reply.

Regards,
Thiru.




Responses

Posted by: Ndebata on: 10/20/2011 [Member] Starter | Points: 25

Up
0
Down
First Create a virtual directory called "FileData" or any name in your web site.
Then try add Events.xml in to it.

In you datalayer create a method add a parameter called FilePath something like
public void SaveXML(string FilePath,....)

Expose the same method format from business layer

Then while calling this SaveXML method from application, try to use
Server.MapPath(@"FileData/Events.xml")
as a parameter to pass.



Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/21/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Debata,
Thanks for your reply.
Actually in check got the string value from DAL to PL and save the xmlstirng to xml file located in current project path.
using the code:
server.mappath("Events.xml")

But it seems your code is good - can you explain me using any example(if possible)

actually we are just call creating an object and call the DAL fuction through BAL.
as in DAL we used to get required details from database and store it in a string value to pass back or do some action with that.
here my required action to do is to save that string into xml file.

Regards,
Thiru.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abdulhaknet on: 10/25/2011 [Member] Starter | Points: 25

Up
0
Down
hi friend ,


Better to use server.mappth() function to specify file path

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response