title: Unhandled Exception: FileSystemException: Cannot open file, path ... (OS Error: No such file or directory, errno = 2)
body: <p>I'm trying to download *.xlsx file using dio.download, and it's throwing the errors:
  Unhandled Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/Android/data/com.example.foodagator_app/files/file.xlsx' (OS Error: No such file or directory, errno = 2)</p>
  <p>Another one error from try/catch block:
  FileSystemException: Creation failed, path = 'File: '' (OS Error: Read-only file system, errno = 30)</p>
  <p>I wrote the permission in androidmanifest for external storage, and also tried temporary directory, but it's not working. Can anyone help me with this? Here is my code</p>
  <pre><code>void download() async {
      var tempDir = await getExternalStorageDirectory();
      File file = File(tempDir!.path + '/file.xlsx');
      try {
        Response response = await dio.download(
          url,
          file,
          options: Options(
            responseType: ResponseType.bytes,
            followRedirects: false,
          ),
        );
  
        var raf = file.openSync(mode: FileMode.write);
        // response.data is List&lt;int&gt; type
        raf.writeFromSync(response.data);
        await raf.close();
      } catch (e) {
        print('Error is: $e');
      }
    }
  
    void readFile() async {
      var tempDir = await getExternalStorageDirectory();
  
      var filePath = tempDir!.path + &quot;/file.xlsx&quot;;
      var bytes = File(filePath).readAsBytesSync();
      var decoder = SpreadsheetDecoder.decodeBytes(bytes, update: true);
      for (var table in decoder.tables.keys) {
        print(table);
        print(decoder.tables[table]!.maxCols);
        print(decoder.tables[table]!.maxRows);
        for (var row in decoder.tables[table]!.rows) {
          print('$row');
        }
      }
    }
  </code></pre>