Articles   Dev Forums   Personalize   Favorites   Member Login   ASP Hosting      Active Users:  90
DevASP - ASP and XML Articles, Samples, Toturials, Sample Chapters and resources for Developers Friday, May 09, 2008
Home
Articles & Samples
ASP Hosting
Dev Search
Dev Forum
Add Your Articles
Add a Listing
Sample Chapters
Directory Feed
Link to US
Contact

Search Directory
Applications
Articles & Samples
Components
Community
Database
Developer Sites
Downloads
Hosting Services
Introduction
Knowledge Base
Sample Chapters
WebCasts

ESET
ASP Directory
Applications
Articles & Samples
Components
Developer Sites
Knowledge Base
Sample Chapters
WebCasts
XML Directory
Applications
Articles & Samples
Developer Sites
Error, Bugs & Fixes
Downloads
Introduction
Knowledge Base
Sample Chapters
WebCasts


How to write to a file using FileSystemObject.

  This Example shows how to write to a file, using FileSystemObject in an ASP Page.

<%
Option Explicit

' Set up Constants
Const ForWriting = 2 ' Input OutPut mode
Const Create = True

Dim MyFile
Dim FSO ' FileSystemObject
Dim TSO ' TextStreamObject

' Use MapPath function to get the Physical Path of file

MyFile = Server.MapPath("textfile.txt")

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set TSO = FSO.OpenTextFile(MyFile, ForWriting, Create)

TSO.write "This is first line in this text File" & vbcrlf
' Vbcrlf is next line character
TSO.write "This is Second line in this text file" & vbcrlf
TSO.write "Writen by devasp visitor at " & Now()
TSO.WriteLine ""

Response.Write " Three lines are writen to textfile.txt <br>"
Response.Write " Local time at server is " & Now()

' close TextStreamObject and
' destroy local variables to relase memory
TSO.close
Set TSO = Nothing
Set FSO = Nothing
%>

Have Questions? Discuss this topic in Dev Forum

DevASP - Privacy - Disclaimer
Copyright © 2008 DevASP.com