System.Diagnostics.Debug.WriteLine( sDescription );
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
Thursday, February 24, 2022
c# - How solve if Console.WriteLine() doesn`t work
In that situation you can try this replacement:
Monday, February 21, 2022
c# - How to download file from the web as string
Useful for example for .xml downloading.
Old (now obsolete method):
string str = "";
#pragma warning disable SYSLIB0014 // Type or member is obsolete
using( var wc = new WebClient() )
{
str = wc.DownloadString( this.URL );
}
#pragma warning restore SYSLIB0014 // Type or member is obsolete
New method:
string str = "";
HttpClient client = new HttpClient();
using ( HttpResponseMessage response = client.GetAsync( this.URL ).Result )
{
using ( HttpContent content = response.Content )
{
str = content.ReadAsStringAsync().Result;
}
}
Subscribe to:
Comments (Atom)