Solved

How to print <% Response.ContentType .... in a file ????

Posted on 2002-04-15
5
289 Views
Last Modified: 2012-08-13
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile("c:\test.txt", true)
objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel"" %>")
Set objFN = Nothing
Set objFS = Nothing
%>


When I ran it, I got this error :

Unterminated string constant

/e.asp, line 4

objFN.WriteLine("<% Response.ContentType = ""application/vnd.ms-excel""
-----------------------------------------------------------------------^


How to fix it ? I must print <% Response.ContentType = "application/vnd.ms-excel" %> into a file.
0
Comment
Question by:decae2001
  • 3
5 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6943981
try

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6943985
fix:

objFN.WriteLine(chr(60) & chr(34) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & 
chr(37) & chr(62))
0
 
LVL 20

Accepted Solution

by:
Silvers5 earned 200 total points
ID: 6943993
fixed final:

<%@ Language=VBScript %>
<%
Set objFS =Server.CreateObject("Scripting.FileSystemObject")
Set objFN = objFS.CreateTextFile(server.MapPath("test.txt"), true)
objFN.WriteLine(chr(60) & chr(37) & " Response.ContentType = " & chr(34) & "application/vnd.ms-excel" & chr(34) & chr(37) & chr(62))
Set objFN = Nothing
Set objFS = Nothing
%>
0
 
LVL 1

Expert Comment

by:falconew
ID: 6944308
Try this:
objFN.WriteLine("<% Response.ContentType = """application/vnd.ms-excel""" %>")

REgards,
Falconew
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 6944498
you don't really need to use the chr function... just make sure you separate the < and the % ....

objFN.WriteLine("<" & "% Response.ContentType .....


ASPGuru
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question