I am trying to read a file placed inside visuals studio 2017 projects folder.
As there is a space in the file path,below code always return 'Error - File does not Exists'.I tried putting a double quotes around the path and replaces all spaces with %20.unfortunately both did not worked for me
Can some one help me to resolve it?
File Path -
C:/Users/Guest/Documents/Visual Studio 2017/Projects/help.txt
Code:
if (fs.existsSync(filePath)) {
fs.readFile(filePath, 'utf8', function (err, contents) {
if (err) {
logger.error("Error while reading the file - " + filePath)
next("Error while reading the file")
} else {
next(contents);
}
});
} else {
logger.error("File does not exist in path - " + filePath)
next("Error - File does not Exists")
}