我希望我的应用程序访问指定的 HTTPS URL 并从该 URL 下载 CSV 文件。
我有以下代码:
程序.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Security;
using System.IO;
namespace httpWebRequest_Test
{
class Program
{
static void Main(string[] args)
{
var webAddr = "https://SFTP URL/xyz.csv";
var httpWebRequest = (HttpWebRequest) WebRequest.Create(webAddr);
httpWebRequest.ContentType = "text/csv";
httpWebRequest.Method = "POST";
var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
//ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
Stream resStream = httpResponse.GetResponseStream();
}
AcceptAllCertification aac = new AcceptAllCertification();
public static RemoteCertificateValidationCallback …Run Code Online (Sandbox Code Playgroud)