简体   繁体   English

使用 c# 控制台从链接自动下载 csv 文件

[英]Automatically download csv file from link using c# console

I am trying to automatically download a csv file from a "https://link.edgepilot.com/s/aa50672c/DEwHBgotZUST8xkYpqNg?u=https://www.visionwheel.com/dealers/export.cfm"我正在尝试从“https://link.edgepilot.com/s/aa50672c/DEwHBgotZUST8xkYpqNg?u=https://www.visionwheel.com/dealers/export.cfm”自动下载 csv 文件

On load of such url in chrome,it shows such page the screenshot of the page and also it automatically downloads the csv file.在 chrome 中加载此类 url 时,它会显示该页面的屏幕截图,并自动下载 csv 文件。

I checked, in that page they have written form submit, so it automatically downloads.On click of the button in the page also it downloads.我检查过,在那个页面中他们已经写了表单提交,所以它会自动下载。点击页面中的按钮也会下载。

I have no idea how to make it in code to download in a specific path using c# console application.Can anyone plz help me.我不知道如何在代码中使用 c# 控制台应用程序在特定路径中下载。任何人都可以帮助我。

I have tried webclient like this我试过这样的webclient

WebClient myWebClient = new WebClient(); WebClient myWebClient = new WebClient();

myWebClient.DownloadFile(remoteUri,fileName); myWebClient.DownloadFile(remoteUri,fileName);

but it downloads the aspx page text not the file.但它下载的是 aspx 页面文本而不是文件。

Plz help me.Thanks in advance.请帮助我。在此先感谢。

using (WebClient client = new WebClient()) 
{
    client.DownloadFile(new Uri(url), @"c:\file.csv");
}

if that "downloads the aspx page text not the file", then you probably have the wrong link?如果“下载 aspx 页面文本而不是文件”,那么您可能有错误的链接?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM