1

I use the following code to parse an XLSX file.

private IExcelDataReader GetExcelDataReaderForFile(string filePath)
{
    FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);

    // Create the excel data reader
    IExcelDataReader excelReader;

    excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
    // Close the stream
    stream.Close();

    // First row are columns names
    excelReader.IsFirstRowAsColumnNames = true;

    return excelReader;
}

Im running this code on my android. The path is subjective to Application.persistentDataPath. The problem here is that Im getting the following strange error,

Access to the path "/tmp" is denied.

How do I sort it out? or is there any other ways to parse xlsx files in Android?

Fábio Nascimento
  • 2,644
  • 1
  • 21
  • 27

1 Answers1

1

You are requesting a file/directory at the root of the drive.

You should use ./tmp (notice the .) or if you insist Application.persistentDataPath + "/tmp"

Riaan Walters
  • 2,587
  • 2
  • 18
  • 30
  • Correct, but you are trying to access that path with `filePath` So the error is not with the code you show, it's with the code you do not show. – Riaan Walters Jul 08 '19 at 09:55