[英]How can I automatically retrieve a CSV file from web, save it in a directory, and access it in C#?
I am working on an application which has to retrieve data from a CSV file online and display it with a click of a button. 我正在开发一个应用程序,该应用程序必须在线从CSV文件中检索数据并单击一下按钮将其显示。 However, how can I automatically store the CSV file in a safe place where I can access the information?
但是,如何自动将CSV文件存储在可以访问信息的安全位置? I am working with Visual Studio C#.
我正在使用Visual Studio C#。
Thank you. 谢谢。
You want to use the WebClient class to make an http request to the server for the csv file. 您要使用WebClient类向服务器发出对csv文件的http请求。 It should read the whole contents as a string which you can then parse and manipulate at your leisure.
它应将整个内容读取为字符串,然后可以在闲暇时对其进行解析和操作。
http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.100).aspx http://msdn.microsoft.com/zh-cn/library/system.net.webclient(VS.100).aspx
Use System.IO.File to write the contents to a file. 使用System.IO.File将内容写入文件。
http://msdn.microsoft.com/en-us/library/system.io.file.aspx http://msdn.microsoft.com/en-us/library/system.io.file.aspx
The FileHelpers are a free and easy to use .NET library to import/export data from fixed length or delimited records in files, strings or streams. FileHelpers是一个免费且易于使用的.NET库,用于从文件,字符串或流中的固定长度或定界记录中导入/导出数据。
The FileHelpers Library FileHelpers库
http://www.filehelpers.com/ http://www.filehelpers.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.