开发者

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. However, how can I automatically store the CSV file in a safe place where I c开发者_JAVA技巧an access the information? I am working with Visual Studio C#.

Thank you.


You want to use the WebClient class to make an http request to the server for the csv file. 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

Use System.IO.File to write the contents to a file.

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.

The FileHelpers Library
http://www.filehelpers.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜