Server-side scripts with ASP

B

Bill Sneddon

Sorry if this is an easy question.

Does Javascript work "out of the box with IIS" as an
Active server page? ie. does it have the ability to open files
ect.?

I tried this command and it does not seem to work.

var fileSys;
var txtFile;
fileSys = new ActiveXObject("Scripting.FileSystemObject");
txtFile = fileSys.OpenTextFile("./junk.txt",1,false);

I can't find examples on the web. What would I search for to find out
about objects the Scripting.FileSystemObject?

Background
I work at a large company with a corperate IT group.
I need to write some server side scripts. The servers they
have are Windows 2000 with IIS installed. If additional
software needs to be installed I will be forced to use VBscript.

Bill
 
L

Laurent Bugnion, GalaSoft

Hi,

Bill said:
Sorry if this is an easy question.

Does Javascript work "out of the box with IIS" as an
Active server page? ie. does it have the ability to open files
ect.?

Yes. You don't need special libraries, JScript is installed. However,
you might need to specify on your pages that JScript should be used
instead of VBScript. To do this, place this line on top of the ASP page:

<%@ Language=JavaScript %>

This should be the first line of the page.

I tried this command and it does not seem to work.

var fileSys;
var txtFile;
fileSys = new ActiveXObject("Scripting.FileSystemObject");
txtFile = fileSys.OpenTextFile("./junk.txt",1,false);

I don't find a OpenTextFile method for the FileSysteObject.

Do you mean:
txtFile = fileSys.CreateTextFile( "c:\\testfile.txt", true );

Note the windows notation (backslash as path separator instead of slash)!!

More documentation about the FileSystemObject: See MSDN
<URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgfsosample.asp>


I can't find examples on the web. What would I search for to find out
about objects the Scripting.FileSystemObject?

Background
I work at a large company with a corperate IT group.
I need to write some server side scripts. The servers they
have are Windows 2000 with IIS installed. If additional
software needs to be installed I will be forced to use VBscript.

Bill

That would be a shame ;-)

HTH,

Laurent
 
S

Steve van Dongen

Hi,

Bill Sneddon wrote:

I don't find a OpenTextFile method for the FileSysteObject.

It's there.

FSO works with real files, not URLs, so use Server.MapPath to get the
path to the file on your filesystem.

txtFile = fileSys.OpenTextFile(Server.MapPath(".") + "\\junk.txt",
1, false);
Note the windows notation (backslash as path separator instead of slash)!!

More documentation about the FileSystemObject: See MSDN
<URL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgfsosample.asp>

Regards,
Steve
 
L

Laurent Bugnion, GalaSoft

Hi,
On Wed, 03 Sep 2003 22:58:16 +0200, "Laurent Bugnion, GalaSoft"



It's there.

I believe you alright ;-) I checked it up in MSDN quite late last night,
and was aware that my unability to find it in the MSDN jungle didn't
mean it was not there ;-)

Laurent
 
B

Bill Sneddon

Thanks All.

It is working now. I think my problem was related to the path.
As Steve suggested.

Thanks again ... glad I don't have to use VB script!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top