yship
14 years agoOccasional Contributor
aqFileSystem.Exists does not seem to work with a .split ReadWholeTextFile list
Hi everyone,
I am struggling to find out why the following code does not find the specified files.
I have a text file with a list of paths, such as "c:\example.dll" separated by new lines
Now when I run the following script (JS):
function Test1()
{
var sourceFile = ".\\ListOfFilesInstalledFiles.txt"
Log.Message(aqFileSystem.Exists(sourceFile));
var locations;
locations = aqFile.ReadWholeTextFile(sourceFile, aqFile.ctUTF8); //read the notepad generated textfile
locations = locations.split("\n");
Log.Message(locations[0]);
Log.Message(aqFileSystem.Exists(locations[0]));
}
The log returns:
True //The ListOfFilesInstalledFiles.txt exists
C:\Testfile.txt //The file path found in the textfile
False //it cannot find the file
Which I find irrational,
If I manually assign : Locations[0]="c:\\Testfile.txt"
It returnes true.
I tried converting the path to string, I tried adding double backslashes in the text file, nothing seems to work.
I was wondering if anyone here has experienced this issue and knows how to get around it?
Thanks ahead,
Yship
I am struggling to find out why the following code does not find the specified files.
I have a text file with a list of paths, such as "c:\example.dll" separated by new lines
Now when I run the following script (JS):
function Test1()
{
var sourceFile = ".\\ListOfFilesInstalledFiles.txt"
Log.Message(aqFileSystem.Exists(sourceFile));
var locations;
locations = aqFile.ReadWholeTextFile(sourceFile, aqFile.ctUTF8); //read the notepad generated textfile
locations = locations.split("\n");
Log.Message(locations[0]);
Log.Message(aqFileSystem.Exists(locations[0]));
}
The log returns:
True //The ListOfFilesInstalledFiles.txt exists
C:\Testfile.txt //The file path found in the textfile
False //it cannot find the file
Which I find irrational,
If I manually assign : Locations[0]="c:\\Testfile.txt"
It returnes true.
I tried converting the path to string, I tried adding double backslashes in the text file, nothing seems to work.
I was wondering if anyone here has experienced this issue and knows how to get around it?
Thanks ahead,
Yship