Classic ASP: Write to file

Using Classic ASP, how can I create a file in the current directory?

This returns an error:
<%

set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(Server.MapPath(".") & "\Test.txt", 2, True)
oTextFile.Write "Test Content"
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

Response.Write("-- Done --")

%>

Open in new window

LVL 10
skijAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try using CreateTextFile:

<%

set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.CreateTextFile(Server.MapPath(".") & "\Test.txt", True)
oTextFile.WriteLine "Test Content"
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

Response.Write("-- Done --")

%>

Open in new window


more info - http://www.w3schools.com/asp/asp_ref_filesystem.asp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skijAuthor Commented:
That code returns this error:
The page cannot be displayed because an internal server error has occurred.

Open in new window

Even these two lines, with no other lines, cause the same error:
<%

set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.CreateTextFile(Server.MapPath(".") & "\Test.txt", True)

Open in new window

How can I debug this and solve the problem?  Thanks.
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
in IIS, in the ASP section, under debugging, there's an option to send errors to the browser.

my guess is it's a permissions issue
0
Dave BaldwinFixer of ProblemsCommented:
I think Big Monty is probably correct.  Every directory that I have wanted to write a file in under IIS has required me to give the IIS user write permissions.  They do not normally have that permission.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.