Click here to Skip to main content
15,906,467 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I want to read csv file from the following URL;O=D/"

file name = timetrial.csv

i tried the code.. its showing all files inside the web..
But iwant to read data only from timetrial.csv

What I have tried:

Dim client As New WebClient()
        Dim data As String = client.DownloadString(";O=D/timetrial.csv")

        Dim table As New DataTable()
        Using parser As New TextFieldParser(New StringReader(data))
            parser.TextFieldType = FieldType.Delimited
            Dim headers() As String = parser.ReadFields()
            For Each header As String In headers
            While Not parser.EndOfData
                Dim fields() As String = parser.ReadFields()
            End While
        End Using

        DataGridView1.DataSource = table
Updated 25-Jan-23 21:28pm

I used your URL in a web browser and saw the list of files in that directory. I found the file and right-clicked on it and selected "copy link address". I paste the link in a web browser and the file opened up.

Here is that link:

As for downloading the file, there are a number of different techniques. The simplest is:
Dim Text = Await New HttpClient().GetStringAsync("")
File.WriteAllText("Timetrial.csv", Text)
Share this answer
Have a look at
WebClient.DownloadFile Method (System.Net) | Microsoft Learn[^]
You will see that here are two overloads of DownloadFile.
You must use the
DownloadFile(String, String)
overload, which accepts a filename as second argument.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900