"Unable to open file ..." notification in Windows 7

44 views
Skip to first unread message

Dariusz Bursztynowski

unread,
Jan 3, 2016, 11:06:56 AM1/3/16
to phantomjs

Hi,

I'm quite new to phantomjs, but the problem I've encountered in Windows 7 starts to drive me mad.

WHAT I NEED AND DO FOR MY APPLICATION

I'm using phantomjs-2.0.0-windows executable. I want to write the results of my measurements to a local file defined as:

  var logfileName = 'file:///'+fs.workingDirectory+'/measurements/'+new Date().toISOString()

and to do so I use code like this:
  fs.write( logfileName, msg + '\n', 'a');

Given the above, I receive run-time notification: Unable to open file 'file:///C:/Users/burszdar/Documents/CommonFolders/TP/CBR/FUSION/Probe/phantomjs-2.0.0-windows/bin/measurements/2016-01-03T15:02:26.628Z'

WHAT I'VE TRIED TO SOLVE THE PROBLEM

I'be checked the access rights for the folders involved and they seem to be OK. Shortening the length of the directory path does not result in any improvement. Guided by suggestions from other sites, I've tested different forms of the folder name separator (slash or backslash) to generate directory/file name strings. I've been using fs.isDirectory and fs.isFile to check whether direcories and folders are recognised, respectively. A strange observation is that ifDirectory works well, i.e., it recognises directories even when different folder name separators are used. Contrary to that, isFile gives FALSE regardless of which form of separator and way of producing the directory name (fs.workingDirectory vs explicit string concatenation) is used. A selection of oprions I've checked is given below.

Any suggestion how to solve the problem (without switchig to Linux ;-) ?

A SELECTION OF OPTIONS TRIED

(At the end of each line below the result returned by isDirectory or isFile is provided. All directories and files referenced are existing.)

testing directories
=============

var fileDir = fs.workingDirectory+'/measurements' // isDirectory = TRUE

var fileDir = fs.workingDirectory+fs.separator+'measurements' // isDirectory = TRUE

var fileDir = 'C:'+fs.separator+'Users'+fs.separator+'burszdar'+fs.separator+'Documents'+fs.separator+'CommonFolders'+fs.separator+'TP'+fs.separator+'CBR'+fs.separator+'FUSION'+fs.separator+'Probe'+fs.separator+'measurements'  // isDirectory = TRUE

var fileDir = fs.workingDirectory // isDirectory = TRUE


testing files
========

var fileName = 'file:///'+fs.workingDirectory+'/test.html' // isFile = FALSE

var fileName = 'file:///'+fs.workingDirectory+fs.separator+'test.html' // isFile = FALSE

var fileName = 'file:///C:/Users/burszdar/Documents/CommonFolders/TP/CBR/FUSION/Probe/phantomjs-2.0.0-windows/bin'+'/test.html' // isFile = FALSE 
Reply all
Reply to author
Forward
0 new messages