Click here to Skip to main content
15,845,103 members
Home / Discussions / C#
   

C#

 
QuestionStreamReader Pin
jojoba20111-Mar-10 18:01
jojoba20111-Mar-10 18:01 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE1-Mar-10 18:49
professionalDr.Walt Fair, PE1-Mar-10 18:49 
QuestionRe: StreamReader Pin
jojoba20111-Mar-10 19:01
jojoba20111-Mar-10 19:01 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE1-Mar-10 19:12
professionalDr.Walt Fair, PE1-Mar-10 19:12 
QuestionRe: StreamReader [modified] Pin
jojoba20111-Mar-10 20:07
jojoba20111-Mar-10 20:07 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE2-Mar-10 5:46
professionalDr.Walt Fair, PE2-Mar-10 5:46 
AnswerRe: StreamReader Pin
V.1-Mar-10 21:01
professionalV.1-Mar-10 21:01 
AnswerRe: StreamReader Pin
carlecomm2-Mar-10 18:57
carlecomm2-Mar-10 18:57 
You can refer to the following code,it can help you.

WebRequest req = null;
WebResponse rsp = null;
try
{
string fileName = "C:\test.xml";
string uri = "http://localhost/PostXml/Default.aspx";
req = WebRequest.Create(uri);
//req.Proxy = WebProxy.GetDefaultProxy(); // Enable if using proxy
req.Method = "POST"; // Post method
req.ContentType = "text/xml"; // content type
// Wrap the request stream with a text-based writer
StreamWriter writer = new StreamWriter(req.GetRequestStream());
// Write the xml text into the stream
writer.WriteLine(this.GetTextFromXMLFile(fileName));
writer.Close();
// Send the data to the webserver
rsp = req.GetResponse();

}
catch(WebException webEx)
{

}
catch(Exception ex)
{

}
finally
{
if(req != null) req.GetRequestStream().Close();
if(rsp != null) rsp.GetResponseStream().Close();
}Function to read xml data from local system
///
/// Read xml data from file
///

/// <param name="file" />
/// <returns>returns file content in xml string format
private string GetTextFromXMLFile(string file)
{
StreamReader reader = new StreamReader(file);
string ret = reader.ReadToEnd();
reader.Close();
return ret;
}

modified 27-May-14 4:54am.

QuestionSpeechSynthesizer memory leak Pin
FocusedWolf1-Mar-10 17:16
FocusedWolf1-Mar-10 17:16 
AnswerRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak1-Mar-10 20:10
mveDave Kreskowiak1-Mar-10 20:10 
GeneralRe: SpeechSynthesizer memory leak Pin
FocusedWolf2-Mar-10 2:46
FocusedWolf2-Mar-10 2:46 
GeneralRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak2-Mar-10 14:04
mveDave Kreskowiak2-Mar-10 14:04 
GeneralRe: SpeechSynthesizer memory leak Pin
FocusedWolf3-Mar-10 19:12
FocusedWolf3-Mar-10 19:12 
GeneralRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak4-Mar-10 2:33
mveDave Kreskowiak4-Mar-10 2:33 
AnswerRe: SpeechSynthesizer memory leak Pin
DudeFX55714-Mar-10 19:42
DudeFX55714-Mar-10 19:42 
QuestionScroll synchronization of two RichTextBox controls Pin
hain1-Mar-10 14:34
hain1-Mar-10 14:34 
AnswerRe: Scroll synchronization of two RichTextBox controls Pin
April Fans1-Mar-10 16:48
April Fans1-Mar-10 16:48 
AnswerRe: Scroll synchronization of two RichTextBox controls Pin
AspDotNetDev1-Mar-10 16:59
protectorAspDotNetDev1-Mar-10 16:59 
Questionif statement? Pin
Iman Mohtashemi1-Mar-10 10:36
Iman Mohtashemi1-Mar-10 10:36 
AnswerRe: if statement? Pin
DaveyM691-Mar-10 12:25
professionalDaveyM691-Mar-10 12:25 
Questionis it possible to do this? Pin
tonyonlinux1-Mar-10 10:13
tonyonlinux1-Mar-10 10:13 
AnswerRe: is it possible to do this? Pin
Saksida Bojan1-Mar-10 10:49
Saksida Bojan1-Mar-10 10:49 
AnswerRe: is it possible to do this? Pin
Luc Pattyn1-Mar-10 10:54
sitebuilderLuc Pattyn1-Mar-10 10:54 
AnswerRe: is it possible to do this? Pin
Dan Mos1-Mar-10 13:32
Dan Mos1-Mar-10 13:32 
GeneralRe: is it possible to do this? Pin
tonyonlinux1-Mar-10 14:36
tonyonlinux1-Mar-10 14:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.