Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Design, HTML And CSS Forums (http://www.go4expert.com/forums/web-design-forum/)
-   -   Empty Spaces In File Name (http://www.go4expert.com/forums/empty-spaces-file-t17246/)

Carlito 1May2009 02:14

Empty Spaces In File Name
 
Hi everyone,

This issue is what brang me to this forum:
Calling OFFLINE files from HTML webpage on local drive using window.setTimeOut to delay most calls. ISSUE: When I call a file w/o empty space in name, this function calls w/o error on page, but I do not know how to do it when file contains empty space(s) in its name.
HTML Code:

function runXZNNespritsPMz()
{
File="E:\\XZNNesprits\\ZZ XZNNesprits PMz.session";
//can only launch such a file when no empty space present in name
WSH=new ActiveXObject("WScript.Shell");
WSH.run(File);
}

How do I correctly write the full path of such a file containing empty spaces in its name?

Carl
XZNN

SaswatPadhi 11May2009 07:06

Re: Empty Spaces In File Name
 
That problem is faced by many, I had also faced in VBScript !!

Well, the solution is to wrap the file-name with an extra pair of quotes.
The modified code looks like this :
Code: java

function runXZNNespritsPMz()
{
      FileName="\"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session\"";
      WSH=new ActiveXObject("WScript.Shell");
      WSH.run(FileName);
}


I think this will work, 'cuz this worked for me in VBScript :smile:

Carlito 13May2009 05:48

Re: Empty Spaces In File Name
 
Quote:

Originally Posted by SaswatPadhi (Post 47555)
That problem is faced by many, I had also faced in VBScript !!

Well, the solution is to wrap the file-name with an extra pair of quotes.
The modified code looks like this :

Code: java
function runXZNNespritsPMz()</p>
<p>{</p>
<p> FileName="\"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session\"";</p>
<p> WSH=new ActiveXObject("WScript.Shell");</p>
<p> WSH.run(FileName);</p>
<p>}



I think this will work, 'cuz this worked for me in VBScript :smile:


Thanks so much SaswatPadhi. You are the first one who ever answered me a question on this forum (my first ever too!). OK I calm down.

I tried your syntax as a var value and it is perfect in js except that there must not be present those two backslashes in between the double double quotes. So that would be:

var whichever_name = '"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session"'

In fact, I started to relocate many of the files and folders I needed to call through js (renaming them without any empty spaces) and found that when you look at the Properties, in WinXP, of a shortcut, it give you the target path embedded by double quotes, and, if no empty spaces in name of file nor of the whole path, it does not embed it in double quotes.

Thanks again to reply me SaswatPadhi.

SaswatPadhi 13May2009 07:33

Re: Empty Spaces In File Name
 
Quote:

Originally Posted by Carlito (Post 47714)
Thanks so much SaswatPadhi. You are the first one who ever answered me a question on this forum (my first ever too!).

The pleasure is all mine and welcome to the forum.

Quote:

Originally Posted by Carlito (Post 47714)
I tried your syntax as a var value and it is perfect in js except that there must not be present those two backslashes in between the double double quotes. So that would be:

var whichever_name = "E:\\XZNNesprits\\ZZ XZNNesprits PMz.session"'

Double double quotes !!!! :crazy: How does that work ? I think it's not supported. Even in VBS :
Code: vb

set WshShell = WScript.CreateObject("WScript.Shell")
FileName = "C:\X Y Z.bat"
WshShell.Run(chr(34)+FileName+chr(34))

So, I thought, you have to use escape sequences in Java.

Can someone explain this to me : how double double quotes work !?

Carlito 13May2009 09:00

Re: Empty Spaces In File Name
 
Quote:

Originally Posted by SaswatPadhi (Post 47722)
The pleasure is all mine and welcome to the forum.



Double double quotes !!!! :crazy: How does that work ? I think it's not supported. Even in VBS :

Code: vb
set WshShell = WScript.CreateObject("WScript.Shell")</p>
<p>FileName = "C:\X Y Z.bat"</p>
<p>WshShell.Run(chr(34)+FileName+chr(34))


So, I thought, you have to use escape sequences in Java.

Can someone explain this to me : how double double quotes work !?

I found an error in my syntax. It really goes like this and I think it is completely legal (someone would need to confirm this though)(many people coding embedded js into HTML like to use single quotation for js related syntax and double quotation for HTML). So the correct and flawlessly performing (no errors on page within IE) syntax for my example is:

Code: Javascript

var whichever_name = '"E:\\XZNNesprits\\ZZ XZNNesprits PMz.session"'


By the way, what are the cool things about VBS?

SaswatPadhi 13May2009 09:42

Re: Empty Spaces In File Name
 
If you want a comparison between VBS and JS, go here : http://msdn.microsoft.com/en-us/libr...loband%29.aspx. :smile:

Carlito 13May2009 23:29

Re: Empty Spaces In File Name
 
Cool


All times are GMT +5.5. The time now is 12:20.