Custom Shopping Cart & eCommerce Merchant Account Integration services

 

Request a Free Quote

Contact Us - Call 1-877-627-2492    


 
Earth Skater Custom eCommerce [Home]
  Authorize.net Certified Developer PayPal Certified Integration CyberSource Certified Developer
      You are here:   Home · Dev Zone · ASP File System Object      
 
eCommerce Hosting
Affiliate Software
Website Analytics
Merchant Accounts
Merchant Integration

Internet Marketing
Content Management
Custom Development
Custom Web Design

Why Earth Skater
Our Clients
Our Partners
     
 
   

ASP File System Object FSO

Syntax

FileSystemObject.OpenTextFile(fname,mode,create,format)
 
Parameter Description
fname Required. The name of the file to open
mode Optional. How to open the file

1=ForReading - Open a file for reading. You cannot write to this file.
2=ForWriting - Open a file for writing.
8=ForAppending - Open a file and write to the end of the file.

create Optional. Sets whether a new file can be created if the filename does not exist. True indicates that a new file can be created, and False indicates that a new file will not be created. False is default
format Optional. The format of the file

0=TristateFalse - Open the file as ASCII. This is default.
-1=TristateTrue - Open the file as Unicode.
-2=TristateUseDefault - Open the file using the system default.

The following code creates a text file (c:\test.txt) and then writes some text to the file:

Change the file name from c:\test.txt to your virtual path in a shared hosting environment; use this code as your file path instead, server.mappath("/test.txt").

<%
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\test.txt",true)     'change to virtual path in shared hosting environment
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>

The following code is to check if a file exists.

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

If (fs.FileExists(server.mappath("/test.txt")))=true Then
      Response.Write("File exists.")
Else
      Response.Write("File does not exist.")
End If

set fs=nothing
%>

The following code is to get a files extension.

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")

Response.Write("The file extension of the file is: ")
Response.Write(fs.GetExtensionName(server.mappath("/test.txt")))

set fs=nothing
%>

The following code is to read from a file.

<%
' create the fso object
set fso = Server.Createobject("Scripting.FileSystemObject")
path = server.mappath("/test.txt")
' open the file
set file = fso.opentextfile(path, 1)  <-- For reading
do until file.AtEndOfStream
Response.write("Name: " & file.ReadLine & " ")
Response.write("Home Page: " & file.ReadLine & " ")
Response.write("Email: " & file.ReadLine & "<p>")
loop
' close and clean up
file.close
set file = nothing
set fso = nothing
%>

 

 

Home | eCommerce Shopping Cart | Affiliate Software | Website Analytics | eCommerce Merchant Accounts | Merchant Account Integration

Help & Support | Contact | Request a Quote | Affiliates | Developer Articles | Marketing Articles | Blog | Policies | Site Map

© 2008

Earth Skater  Boca Raton Web Design Florida FL USA  

Content last updated 7/30/2008