0

I am trying to read .csv file on Windows Phone 8. And I am writing below code. This similar code runs on C#. But when I click to run I was getting error.

PivotPage.xaml.cs:

List<double[]> inputs = new List<double[]>();
List<double[]> outputs = new List<double[]>();

using (StreamReader okuyucu = File.OpenText(".\\TrainData\\iris_data.csv")) //this is giving error
{

Bla bla bla

}

Error: An exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Could not find a part of the path 'C:\Data\Programs{36F60104-9832-417C-AFDC-91B66CB56343}\Install\TrainData\iris_data.csv'.

I am trying ".\TrainData\iris_data.csv" , "\TrainData\iris_data.csv" , " C:\\Users\OSMAN\\Documents\\Visual Studio 2013\\Projects\\PanoramaApp1\\PanoramaApp1\\TrainData\\iris_data.csv" and another version.

How can I read iris_data.csv file.

Thanks in advance. (sorry my language)

Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44
Osman Villi
  • 346
  • 2
  • 24

1 Answers1

1

You should use the StorageFile class to load the application resource.

Like this:

var uri = new System.Uri("ms-appx:///TrainData/iris_data.csv");
var file = Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
Mikael Dúi Bolinder
  • 2,080
  • 2
  • 19
  • 44