Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenTextFile Issue

Status
Not open for further replies.

captedgar

Programmer
Dec 4, 2009
20
0
0
GB
Hi there
One of the lines of my code is as follows
var objTestFile=x.OpenTextFile(strDir, ForReading,false);

What this does is opens a temp file within a shared folder and performs the required task.

For some strange reason, if i include a space in the name of the shared folder. For ex: "Test this please" instead of TestThisPlease,

The script fails to work.

Can anyone please advice what's the issue with this

regards
 
Difficult to say without knowing the exact error and the code inside the x

Cheers,
Dian
 
I agree with Dan. Put either single quotes ' or double-quotes " aruond the line.
 
Hi Guys

Where do i have to insert quotes?

strDir variable = \\IP Address Of Server\g$\Folder1\SubFolder1\2009_12_24_11_50_15_307_radCEEF.tmp

So when OpenTextFile method calls this variable during the execution of the script, then i get a message on the cmd prompt saying File not found.
 
Something to this affect:

strDir variable = '\\IP Address Of Server\g$\Folder1\SubFolder1\2009_12_24_11_50_15_307_radCEEF.tmp'
 
And sorry should have clarified a litte more. What I mentioned it right on but to provide some reasoning and explanation...it there is a space or special character that could be construed as something else you need to put those in quotes.

There are times where you will have to escape out an escape character in which case every location you have a "\" you would need to escape that with another "\".

Like this:

strDir variable = '\\\\IP Address Of Server\\g$\\Folder1\\SubFolder1\\2009_12_24_11_50_15_307_radCEEF.tmp'


Hope this helps.
 
Hi davism

One of the values strDir =
'\\\\IP Address Of Server\\g$\\Folder1\\SubFolder1\\2009_12_24_11_50_15_307_radCEEF.tmp'

is a temp file which gets created during my the execution of the scripts and actually gets deleted before the end of the script.

So in essence
var strDir=ReleaseRoute+strRDir+'\\'+strTmpName;
where ReleaseRoute, strRDir and strTmpName are all other variable which adds upto \\\\IP Address Of Server\\g$\\Folder1\\SubFolder1\\2009_12_24_11_50_15_307_radCEEF.tmp

So i'm not sure where to put the quotes really
 
You can do something like:

var strDir="'" + ReleaseRoute+strRDir+'\'+strTmpName + "'";
strDir.replace("\", "\\"));

Granted I haven't ran this but that is just a quick response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top