Reading .csv-file from Silverlight project

Dec 3, 2012 at 8:08 PM
Edited Dec 3, 2012 at 8:09 PM

Hi

I'm trying to read a .csv file from Silverlight project but keep on getting security exception error: "File operation not permitted. Access to path 'MyFile.csv' is denied."

Can I refer to .csv-file just by using the file path, or what would be a correct way to refer to the file?

Now my method goes like this (copy/paste from the help file):

 using (CsvReader reader = new CsvReader(@"MyFile.csv"))
            {
                reader.ValueSeparator = ',';
                reader.ReadHeaderRecord();
                DataRecord record = null;

                while ((record = reader.ReadDataRecord()) != null)
                {
                    //System.Console.WriteLine("{0} is {1} years old", record["Name"], record["Age"]);
                }
            }

I get the same error when giving the full path to file (at this point it's a local file/folder). The file is included in the project, or that's what it looks to me.

As you must have noticed I'm a newbie and with the help of KBCsv was hoping to avoid using ObservableCollection etc.

Thanks for any help!

Coordinator
Dec 4, 2012 at 11:49 AM

Hi jello,

This actually has nothing to do with KBCsv as such and more to do with Silverlight's sandboxing. Please read up on Silverlight's application security model. Here might be a good place to start.

Best,
Kent 

Dec 18, 2012 at 7:48 PM

Hi

Yep, you're right. It doesn't seem to be KBCsv related at all. I've tried to work my way out by getting the .csv file to resourceStream and played around with the csv files' build action/output directory options, but no luck yet.

But I think that's another issue, not KBCsv :)