By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,536 Members | 1,800 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,536 IT Pros & Developers. It's quick & easy.

help with Server.CreateObject("Scripting.FileSystemObject")

P: n/a
bt

I am just beginning with asp and have gotten an error that I need some
help with. I posted a pair of files to an online ASP host server. The
files are in the same directory; one is readfile.asp which should open
the other which is a simple text file - newText.txt .

Here is readfile.asp :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Reading Text Files</title>
</head>

<body>
<b>An Example of reading a .txt file and hopefully adding some
formatting.</b>
<hr>
<%

set tfile=Server.CreateObject("Scripting.FileSystemObj ect")
set TFStream=tfile.OpenTextFile("newText.txt")
textprinter=TFStream.readall()

%>
<p>
<%=textprinter%>

</body>
</html>

Here is the error msg that results:

Microsoft VBScript runtime error '800a0035'
File not found
/Test-BDT/readfile.asp, line 13

Where line 13 is:
set tfile=Server.CreateObject("Scripting.FileSystemObj ect")
MY Qustions:

-Why didn't it work?
-How do I get it to work? (I suppost I could do a server side include,
but I'd like to figure out the how& why of this code first.
-I may have a path problem. Can someone point me to a good reference
about referencing path in this code?

thanks a lot, BDT


Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Change;

set TFStream=tfile.OpenTextFile("newText.txt")

to

set TFStream=tfile.OpenTextFile(Server.MapPath("newTex t.txt"))

Btw, unless I'm mistaken (and no offence intended), shouldn't you already
know this if your offering advice to others that do not?

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"bt" <bt@.com> wrote in message
news:4n********************************@4ax.com...

I am just beginning with asp and have gotten an error that I need some
help with. I posted a pair of files to an online ASP host server. The
files are in the same directory; one is readfile.asp which should open
the other which is a simple text file - newText.txt .

Here is readfile.asp :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Reading Text Files</title>
</head>

<body>
<b>An Example of reading a .txt file and hopefully adding some
formatting.</b>
<hr>
<%

set tfile=Server.CreateObject("Scripting.FileSystemObj ect")
set TFStream=tfile.OpenTextFile("newText.txt")
textprinter=TFStream.readall()

%>
<p>
<%=textprinter%>

</body>
</html>

Here is the error msg that results:

Microsoft VBScript runtime error '800a0035'
File not found
/Test-BDT/readfile.asp, line 13

Where line 13 is:
set tfile=Server.CreateObject("Scripting.FileSystemObj ect")
MY Qustions:

-Why didn't it work?
-How do I get it to work? (I suppost I could do a server side include,
but I'd like to figure out the how& why of this code first.
-I may have a path problem. Can someone point me to a good reference
about referencing path in this code?

thanks a lot, BDT

Jul 19 '05 #2

P: n/a
bt
Many thanks, it worked like a charm.

I think that I figured out what was wrong with my 'version'. I copied
it from a book that I'm working thru, but the book assumes that one is
working with a local PWS/IIS, not a remote internet host. Does that
explain my original problem?

I must admit that I haven't yet got a firm grasp of this stuff. I've
done a bit HTML and JavaScript over the years, but ASP is all new to
me. Since most of the references I've used refer to local PWS/IIS
instead of a remote internet host, it's been even more difficult. I
have posted a separate request for an 'ASP book recommendation' and
got some good ideas to pursue.

Again, thanks for the info. By the way, I didn't follow your comment
about my 'offering advise to others.' I'm sure not intending to do
that and I'm not sure how I gave that appearance.

cheers, BDT
On Tue, 22 Jun 2004 19:05:05 +0100, "Steven Burn" <pv*@noyb.com>
wrote:
Change;

set TFStream=tfile.OpenTextFile("newText.txt")

to

set TFStream=tfile.OpenTextFile(Server.MapPath("newTex t.txt"))

Btw, unless I'm mistaken (and no offence intended), shouldn't you already
know this if your offering advice to others that do not?


Jul 19 '05 #3

P: n/a
Glad you got it sorted out :o)

As for my comment, just ignore me.... I assumed something from;

************************
<title>Reading Text Files</title>
</head>

<body>
<b>An Example of reading a .txt file and hopefully adding some
formatting.</b>
************************

and obviously shouldn't have..... (I do that occasionally)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"bt" <bt@.com> wrote in message
news:vh********************************@4ax.com...
Many thanks, it worked like a charm.

I think that I figured out what was wrong with my 'version'. I copied
it from a book that I'm working thru, but the book assumes that one is
working with a local PWS/IIS, not a remote internet host. Does that
explain my original problem?

I must admit that I haven't yet got a firm grasp of this stuff. I've
done a bit HTML and JavaScript over the years, but ASP is all new to
me. Since most of the references I've used refer to local PWS/IIS
instead of a remote internet host, it's been even more difficult. I
have posted a separate request for an 'ASP book recommendation' and
got some good ideas to pursue.

Again, thanks for the info. By the way, I didn't follow your comment
about my 'offering advise to others.' I'm sure not intending to do
that and I'm not sure how I gave that appearance.

cheers, BDT
On Tue, 22 Jun 2004 19:05:05 +0100, "Steven Burn" <pv*@noyb.com>
wrote:
Change;

set TFStream=tfile.OpenTextFile("newText.txt")

to

set TFStream=tfile.OpenTextFile(Server.MapPath("newTex t.txt"))

Btw, unless I'm mistaken (and no offence intended), shouldn't you already
know this if your offering advice to others that do not?

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.