Windows Scripting - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

E-Commerce is taking over the traditional commerce practices. It is of special concern for the IT students. Following are the key points of these Lecture Slides : Webbed Structure, Web Site Organization, Content Fits, Hierarchical Structure, Business Organizational, Additional Details, Combines Structured, Crosslinked, Pages, Enable Visitors

Typology: Slides

2012/2013

Uploaded on 07/30/2013

post_box
post_box 🇮🇳

4.7

(3)

113 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Building & Managing Web Sites
FileSystemObject Object
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Windows Scripting - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Building & Managing Web Sites

FileSystemObject Object

Windows Scripting

  • Microsoft Windows Script Host (WSH)

allows running of VBScript and JScriptnatively within the base Operating System.

  • Introduced with Win98+, but available for

Windows 95, 98, NT 4, and Win2000operating systems.

  • Using scripting languages, can write script

to automate common tasks, and to createpowerful macros and logon scripts.

Windows Scripting Example

On a Windows computer with Windows Script,

create a file in Notepad called “Hello.vbs” withthe following contents, then double-click it to runthe script. Set fs =

CreateObject("

Scripting.FileSystemObject

")

Set a = fs.CreateTextFile("c:\test.txt", True)a.WriteLine(”Hello World.")a.Closeset fs=nothing

ASP and FileSystemObject (FSO)^ •

ASP uses native objects (Response), installablecomponents (Browser Capabilities), & WSHobjects (e.g., FileSystemObject)

-^

The FileSystemObject (FSO) is the “window” toserver’s file system. Allows querying andmanipulation of:^ – text files– folders– drives

-^

FSO often offers many ways to do the same thing

Using FSO in ASP

  • FSO has one property - FSO.Drives• Returns a

Drives

collection consisting of all

Drive

objects available on the local machine.

Set fso =

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

fso.Drives

For Each d in dc

Response.Write d & “
” Next

Many FSO Properties

-^

BuildPath

-^

CopyFile

-^

CopyFolder

-^

CreateFolder

-^

CreateTextFile

-^

DeleteFile

-^

DeleteFolder

-^

DriveExists

-^

FileExists

-^

FolderExists

-^

GetAbsolutePathName

-^

GetBaseName

-^

GetDrive

-^

GetDriveName

-^

GetExtensionName

-^

GetFile

-^

GetFileName

-^

GetFolder

-^

GetParentFolderName

-^

GetSpecialFolder

-^

GetTempName

-^

MoveFile

-^

MoveFolder

-^

OpenTextFile

GetFolder and Files

  • Instantiate the Folder’s file collection to view

the files in the folder.

  • Can query each file’s properties like Name,

Size, Path, etc.

sDir = Server.MapPath(".")Set fso =

Server.CreateObject("Scripting.FileSystemObject") Set objFldr = fso.GetFolder(sDir)Set objFileColl = objFldr.FilesFor Each file in objFileColl

response.write file.Name & "
" Next

GetFile Property

  • Another way to query a specific files’

properties.

Set fs =

CreateObject("Scripting.FileSystemObject") Set objFile = fs.GetFile("c:\test\test.txt")Response.Write " Name:" & objFile.NameResponse.write " Size:" & objfile.Size & "
"

TextStream Object

  • TextStream object allows access to content

of text files

  • Manipulations normally done on a line by

line basis using methods like ReadLine,WriteLine, Skip, etc.

  • Manipulations can only move the file cursor

forward.

OpenTextFile Method and

TextStream Example

Const ForAppending = 8sDir = Server.MapPath(".") & "\testfile.txt"Set fs =

Server.CreateObject("Scripting.FileSystemObject") Set objFile = fs.OpenTextFile(sDir, ForAppending)objFile.WriteLine(WeekdayName(WeekDay(date())))objFile.Close