Writing Files in Web Service
I have a webservice that has a webmethod that looks like this:
public string WriteStudentFile(string user_id, string StudentXML)
string newFile = ConfigurationSettings.AppSettings["Student_Physical"];
newFile += user_id + ".xml";
//I tried both FileStream s and Stream s
Stream s = new FileStream( newFile, FileMode.Create );
StreamWriter sw = new StreamWriter(s);
sw.Write( StudentXML );
Every time I invoke the service it faluts. However it works when I test it inside a simple Page_Load Block. When I debug this code block in the Page_Load function it hits the 4th Line (Stream s = new FileStream...) it jumps back to the first line where I declare newFile. It then continues to execute the code line by line.
Does this have to do with why it is faulting? Why does this happen. Is there any other way I can write a simple file?
Last edited by hoyaabanks; 10-12-2005 at 12:41 AM.
When you say that it "faults," do you mean that you get an error message? If so, what is it? If not, enclose your code in a try...catch block and log or display the Message property of the exception object in the catch block.
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Last Post: 06-11-2012, 09:10 PM
By Taiwo Ayedun in forum .NET
Last Post: 10-15-2002, 06:18 AM
By Constance J. Petersen in forum .NET
Last Post: 08-28-2002, 11:06 PM
By Srividhya in forum .NET
Last Post: 07-12-2002, 12:17 PM
Last Post: 04-03-2001, 08:28 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center