invalid file identifier. use fopen to generate a valid file identifier
55 visualizaciones (últimos 30 días)
Hi, I have a problem with extracting data from my main code. I generated a .exe archive and I want to extract some data to a .txt archive. When I run the code in Maltab it works perfectly but in the .exe I got the error message: invalid file identifier. use fopen to generate a valid file identifier.
How can I fix it?. Thank you very much.
Muhammed Yaseen el 17 de Ag. de 2021
This is due to the fact that all deployed applications look for a file relative to the "ctfroot", unless the file has been packaged along with the application while compiling it.
As a workaround, use the entire path of the file as the argument to the "fopen" command as shown below:
>> [FileName,PathName] = uigetfile('*.csv')
>> fullpath = [PathName FileName];
>> fid = fopen(fullpath);
The file identifier would now be valid.
For more details on "ctfroot", you can refer this link.