Learnthat.com Free Certification and Computer Online Courses
ThatNetwork.com Internet Media Network Givethat.com free gift ideas Definethat.com - Free technical definitions, define Free Romance Tips, Romantic Tips, Date Ideas Free POD publisher comparison print on demand
Learnthat.com Free A+ Certification, Computer Classes, Certification Courses, Business, Lifestyle, ApplicationsFree business tutorials and definitionsFree certification tutorials and definitionsFree computer and technical tutorials and technical definitionsFree Finance Tutorials and DefinitionsFree House Repair TutorialsFree Lifestyle and Fun Tutorials
  All Online CoursesNew Courses QuickTipsWord DefinitionsSubmit a TutorialLinks
÷ Resources
Home
free tech tutorials
Free Tutorials
free tech tutorials
Certifications
free tech tutorials
Definitions
free tech tutorials
Resources/Links
free tech tutorials
Forums
free tech tutorials
Distance Education
free tech tutorials
Highest Rated Tutorials
÷ Popular Tutorials
÷ New Tutorials

Active Server Pages (ASP)

 

Accessing the File System

The FileSystemObject Object

The FileSystemObject object lets you create and work with files and directories on the server. For example, you can create a file, write data to it and then delete it when the file is no longer necessary. You can also determine whether or not certain files exist, as well as their locations, extensions and other information.

FileSystemObject Object: Methods

BuildPath

Adds a folder or file name to a path.

CopyFile

Copies a file from one location to another.

CopyFolder

Copies a folder and all its files from one location to another.

CreateFolder

Creates a new folder.

CreateTextFile

Creates a new text file using the TextStream object.

DeleteFile

Deletes a file.

DeleteFolder

Deletes a folder and all its files.

DriveExists

Determines whether or not a drive exists on the server.

FileExists

Determines whether or not a file exists on the server.

FolderExists

Determines whether or not a folder exists on the server.

GetAbsolutePathName

Returns the full path (from the root) for the specified folder or file.

GetBaseName

Returns the base name (without the extension) of the specified file or folder.

GetDrive

Creates an instance of the Drive object.

GetDriveName

Returns the drive containing the specified file.

GetExtensionName

Returns the extension of the specified file.

GetFile

Creates an instance of the File object.

GetFileName

Returns the file or folder name specified in a path.

GetFolder

Creates an instance of the Folder object.

GetParentFolderName

Returns the name of the parent folder for the specified file.

GetSpecialFolder

Returns the path of a special Windows folder. 0 returns the path for the folder containing the operating system; 1 returns the path for the folder containing libraries and drivers; 2 returns the path for the Temp folder.

GetTempName

Generates a temporary file or folder with a random name.

MoveFile

Moves a file from one location to another on the server.

MoveFolder

Moves a folder and all its files from one location to another on the server.

OpenTextFile

Opens a file using the TextStream object.


FileSystemObject Object: Properties

Drives

Returns a collection of Drive objects.

The following code determines whether or not a certain file (temp.txt) exists on the server and, if it does, deletes it:

<HTML>

<HEAD>

</HEAD>

<BODY>

<%

Dim varFileSystem

Set varFileSystem=Server.CreateObject("Scripting.FileSystemObject")

If varFileSystem.FileExists("c:\inetpub\wwwroot\temp.txt")=true then

varFileSystem.DeleteFile("c:\inetpub\wwwroot\temp.txt")

End If

%>

</BODY>

</HTML>

Once you've created a FileSystemObject object, you can use its methods to create instances of the TextStream object, the File object, the Folder object and the Drive object. All of these have methods and properties of their own that let you create and manipulate specific files, folders and drives on the server.

 

by Summer Doucet

Find more free Internet tutorials from Learnthat.com.

More Information:

Help us by rating this tutorial: [---] [--] [+] [++] [+++]
[---] lowest; [+++] highest

 

 

 


Learn: Free Tutorials - Links to Free Tutorials
Understand: Free Technical Definitions - ExplainThat Whitepapers
Use: Certification Section - Discussion Forum

Visit Our Network Sites:

DefineThat.com Technical Defintions Romancetips.com
Free Gift Ideas - GiveThat Planthat.com Free Unique Business Ideas
PublishOnDemand.net - Learn about Print on Demand (POD) - Self Publishing Seekthat.com - Technical Search Engine
ThatNetwork.com  

About Us : Contact Us : Advertise : Privacy Information

© 1998-2004 Learnthat.com