Read from .csv file at startup RRS feed

  • Question

  • Hi, I am making my first app and I need to read data from a csv file into a list. I first created this functionality on a console application, but now when I try to use the same code it does not work.

    class FoodDataBase {
            private List<Food> foodDataBase = new List<Food>();
            private string locationOfCSVFile = "C:\\Egen Programmering\\LivsmedelsDatabas\\LivsmedelsDatabas\\LivsmedelsDatabas.csv";
            public FoodDataBase() {
            private bool PopulateFoodDataBase() {
                // connect reader to the CSV file
                var reader = new StreamReader(File.OpenRead(@locationOfCSVFile));
                if (reader == null) {
                    return false;

    But I get an error message saying "The name 'File' does not exist in the current context". I have googled around a bit but can´t find an easy way to do it. Is there not any good way of doing this in WinRT? Should I convert my csv file to something else?

    Saturday, February 14, 2015 10:16 AM


  • Hi PontusL,

    As I can see from your code, you are trying to read a file from a forbidden place, see this for more information: File access and permissions.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by PontusL Sunday, February 15, 2015 4:38 PM
    Sunday, February 15, 2015 1:41 AM

All replies