I have some file names in "LATIN" but the fs.existsSync function is not able to recognise it
1689017335025-Naan En Nesarudaiyavan â mix.json
I tired with buffer too but still not able to get the proper response.
I am providing the proper path of the file too but still its not detecting that file.
I am using the fs module in electron js.
Other files other than Latin are been properly detected by fs.existsSync
const localDownloadPath = path.join(app.getPath('userData'), ${endpath}/${detail.name});
if(fs.existsSync(localDownloadPath)){
return true;
}else {return false;}
2
Answers
As said in Node.js docs,
So if you want to read/open a file, rather call the function and catch errors.
Example of
fs.readFile()
:PS:
I tried what you described in question as not working for you and it works well for me. Check if you wrote that filename correctly.
Screenshot
It might be an encoding issue. The fs.existsSync() function may not recognize file names containing non-ASCII characters or characters outside the standard character set.
To ensure proper recognition of file names with non-ASCII characters, you can try using the fs.readdirSync() function instead.
e.g.