Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
QuestionStreamReader Pin
jojoba20111-Mar-10 17:01
jojoba20111-Mar-10 17:01 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE1-Mar-10 17:49
professionalDr.Walt Fair, PE1-Mar-10 17:49 
QuestionRe: StreamReader Pin
jojoba20111-Mar-10 18:01
jojoba20111-Mar-10 18:01 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE1-Mar-10 18:12
professionalDr.Walt Fair, PE1-Mar-10 18:12 
QuestionRe: StreamReader [modified] Pin
jojoba20111-Mar-10 19:07
jojoba20111-Mar-10 19:07 
AnswerRe: StreamReader Pin
Dr.Walt Fair, PE2-Mar-10 4:46
professionalDr.Walt Fair, PE2-Mar-10 4:46 
AnswerRe: StreamReader Pin
V.1-Mar-10 20:01
professionalV.1-Mar-10 20:01 
AnswerRe: StreamReader Pin
carlecomm2-Mar-10 17:57
carlecomm2-Mar-10 17: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 16:16
FocusedWolf1-Mar-10 16:16 
AnswerRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak1-Mar-10 19:10
mveDave Kreskowiak1-Mar-10 19:10 
GeneralRe: SpeechSynthesizer memory leak Pin
FocusedWolf2-Mar-10 1:46
FocusedWolf2-Mar-10 1:46 
GeneralRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak2-Mar-10 13:04
mveDave Kreskowiak2-Mar-10 13:04 
GeneralRe: SpeechSynthesizer memory leak Pin
FocusedWolf3-Mar-10 18:12
FocusedWolf3-Mar-10 18:12 
GeneralRe: SpeechSynthesizer memory leak Pin
Dave Kreskowiak4-Mar-10 1:33
mveDave Kreskowiak4-Mar-10 1:33 
AnswerRe: SpeechSynthesizer memory leak Pin
DudeFX55714-Mar-10 18:42
DudeFX55714-Mar-10 18:42 
QuestionScroll synchronization of two RichTextBox controls Pin
hain1-Mar-10 13:34
hain1-Mar-10 13:34 
AnswerRe: Scroll synchronization of two RichTextBox controls Pin
April Fans1-Mar-10 15:48
April Fans1-Mar-10 15:48 
AnswerRe: Scroll synchronization of two RichTextBox controls Pin
AspDotNetDev1-Mar-10 15:59
protectorAspDotNetDev1-Mar-10 15:59 
Questionif statement? Pin
Iman Mohtashemi1-Mar-10 9:36
Iman Mohtashemi1-Mar-10 9:36 
AnswerRe: if statement? Pin
DaveyM691-Mar-10 11:25
professionalDaveyM691-Mar-10 11:25 
Questionis it possible to do this? Pin
tonyonlinux1-Mar-10 9:13
tonyonlinux1-Mar-10 9:13 
AnswerRe: is it possible to do this? Pin
Saksida Bojan1-Mar-10 9:49
Saksida Bojan1-Mar-10 9:49 
AnswerRe: is it possible to do this? Pin
Luc Pattyn1-Mar-10 9:54
sitebuilderLuc Pattyn1-Mar-10 9:54 
AnswerRe: is it possible to do this? Pin
Dan Mos1-Mar-10 12:32
Dan Mos1-Mar-10 12:32 
GeneralRe: is it possible to do this? Pin
tonyonlinux1-Mar-10 13:36
tonyonlinux1-Mar-10 13: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.