question

PolachanPaily-6650 avatar image
0 Votes"
PolachanPaily-6650 asked sreejukg answered

CSVhelper to read csv file from ftp server

Please can you any one help me how to read csv file from ftp server using CSVhelper. I have to read the file from "ftp://myfiles.com/download". If search the google I can see CSV helper is being used to read only local csv file not from ftp. Please any help would be very appreciated

Thanks
Pol

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

sreejukg avatar image
1 Vote"
sreejukg answered

Since your file is in FTP, first you need to download file. You may use WebClient or FTPWebRequest class to download the file. You can load your file to a MemoryStream and let the CSVHelper reads the file from the memorystream. Refer this https://joshclose.github.io/CsvHelper/examples/prerequisites/streams/

A sample is here:
https://github.com/JoshClose/CsvHelper/issues/1412#issuecomment-551122734

Note: for the above sample, it uses MemoryStream, in your case, you can download the file from FTP to byte[] and then construct a MemoryStream from the byte[], then use CSVHelper






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.