.Net C# Development

Reading CSV

StreamReader reader = new StreamReader(Server.MapPath("~/App_Data/country.csv"));
            List<SelectListItem> searchList = new List<SelectListItem>();
            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                searchList.Add(new SelectListItem() { Value = line, Text = line });
            }
            // searchList will hold all the values of the CSV

Leave a Reply

Your email address will not be published. Required fields are marked *