How do I create a directory on FTP server using C#?

Use FtpWebRequest, with a method of WebRequestMethods.Ftp.MakeDirectory. For example: using System; using System.Net; class Test { static void Main() { WebRequest request = WebRequest.Create(“ftp://host.com/directory”); request.Method = WebRequestMethods.Ftp.MakeDirectory; request.Credentials = new NetworkCredential(“user”, “pass”); using (var resp = (FtpWebResponse) request.GetResponse()) { Console.WriteLine(resp.StatusCode); } } }

Download file with WebClient or HttpClient?

You can do it natively with .Net 4.5+. I tried doing it your way and then I just found a method in Intellisense that seemed to make sense. https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.copytoasync?view=netframework-4.7.2 uri = new Uri(generatePdfsRetrieveUrl + pdfGuid + “.pdf”); HttpClient client = new HttpClient(); var response = await client.GetAsync(uri); using (var fs = new FileStream( HostingEnvironment.MapPath(string.Format(“~/Downloads/{0}.pdf”, pdfGuid)), … Read more

DataBufferLimitException: Exceeded limit on max bytes to buffer webflux error

This worked for me: Create a @Bean in one of your configuration classes or the main SpringBootApplication class: @Bean public WebClient webClient() { final int size = 16 * 1024 * 1024; final ExchangeStrategies strategies = ExchangeStrategies.builder() .codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(size)) .build(); return WebClient.builder() .exchangeStrategies(strategies) .build(); } Next, go to your desired class where you want … Read more

Set timeout for webClient.DownloadFile()

My answer comes from here You can make a derived class, which will set the timeout property of the base WebRequest class: using System; using System.Net; public class WebDownload : WebClient { /// <summary> /// Time in milliseconds /// </summary> public int Timeout { get; set; } public WebDownload() : this(60000) { } public WebDownload(int … Read more

WebClient.DownloadString results in mangled characters due to encoding issues, but the browser is OK

It’s not lying. You should set the webclient’s encoding first before calling DownloadString. using(WebClient webClient = new WebClient()) { webClient.Encoding = Encoding.UTF8; string s = webClient.DownloadString(“http://export.arxiv.org/api/query?search_query=au:Freidel_L*&start=0&max_results=20”); } As for why your alternative isn’t working, it’s because the usage is incorrect. Its should be: System.Text.Encoding.UTF8.GetString()