Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printing and ASP
Message
De
20/06/2001 22:52:46
 
 
À
20/06/2001 14:50:34
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00521615
Message ID:
00521744
Vues:
21
>I would like to know how can I print a text file located on my server from an ASP page...Thx!

You cannot automatically print to the client. However, you can display the file as plain text on the browser, for the user to print using the browser's "Print" command.
For example:
set fso = createobject("scripting.filesystemobject")
Set f = fso.OpenTextFile("c:\myfile.txt")
Response.ContentType = "text/plain"
Response.Write f.ReadAll
Set f = nothing
Set fso = nothing
Response.End
You can use Server.MapPath to get the physical directory where the file is located, if you don't know it:
myfile = Server.MapPath("myfile.txt")
'then use
Set f = fso.OpenTextFile(myfile)
or, you can simply re-direct the user to your text file, and the browser will open it as text, after which the user can print it:
response.redirect "c:\myfile.txt"
Hope this helps.
Andres M. Chiriboga, MCSE, MCP+I
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform