wayne plourde

software architect mcad mcsd scjp

home | articles | book | resume | projects | contact

19 - Working with Files (Outline and Notes)

ASP 3.0 The Complete Reference

Chapter 19

Working with Files (Outline and Notes)

best practices in handling files, creating directories, and creating files.

Unstructured data.

Manipulating files on the server

Uploading files to the server

Three techniques for File management and editing

ADO

WebDAV

Office Server Extension

Searching files based data

Manipulating Files on the Server

Error Logs

Can be used on the client in controlled situations

Allow local permission

Use in conjunction with OLE Srructured Data Object

FileSystemObject Object Model

Scripting Components

Figure 1: FileSystem Object Model

Collections

Drives

Provides a list of the drives available to the system.

Files

Provides a list of all files contained within a folder.

Folders

Provides a list of all the folders within a Folder.

Objects

Object

Description

FileSystemObject

Root Object.

Drive

Retrieve information about a drive avaliable to the system.

File

Create, delete, or move a file. Retrieve and set file properties,

Folder

Create, delete, or move folders. Retrieve and set folder properties.

TextStream

Allows you to read and write text files.

What you need

Part of the Scripting Languages

The Example Creating your own error log

Error Log

Figure 2: Screen Shot of Log Event

VBScript

1

2

3

4

5

6

7

8

9

10

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

Instantiation

VBScript

1

2

3

4

5

6

7

8

9

10

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

Setting Permissions

Must have read / write permissions on the directories and files you plan to work

NTFS permission

Figure 3: Screen Shot of Permissions Dialog

IIS Permissions

Figure 4: Screen Shot of Permission Dialog

Creating Files and Directories

VBScript

1

2

3

4

5

6

7

8

9

10

Reading and Writing Files

VBScript

1

2

3

4

5

6

7

8

9

10

File Upload

Third Party Components bring Added Value

Easy to create your Own

Use the standard for Post

Third Party Components

Posting Acceptor (part of Microsoft SiteServer),

AspSmartUpload (Advantys),

AspUpload (PersistsSoftware),

SA-FileUp (Software Artisans)

file type id

multiple files

Creating your own File Uploader with Scripting

Creating the Posting Form

VBScript

1

2

3

4

5

6

7

8

9

10

Creating the ASP Acceptor Page

VBScript

1

2

3

4

5

6

7

8

9

10

Request.BinaryRead

VBScript

1

2

3

4

5

6

7

8

9

10

Reconstructing and Saving the File

VBScript

1

2

3

4

5

6

7

8

9

10

Web Distributed Authoring and Versioning (WebDAV)

Web Distributed Authoring and Versioning, is a set of extensions to HTTP 1.1 that enable users to read and write documents over the Web.\

adds the ability to write and control files

independent protocol

XML Based

Support on Apache and Python

You can use Web Folders with servers that meet the following requirements:

The server must support WEC (FrontPage Extensions 97, 98 or 99) or it must be a WebDAV server. WebDAV, or Web Distributed Authoring and Versioning, is a set of extensions to HTTP 1.1 that enable users to read and write documents over the Web. For additional information about WebDAV, see the following Web site:

http://www.ietf.org/html.charters/webdav-charter.html

You must have at least Author and Browse permission on the server (for example, in FrontPage Explorer). In addition, you must have the appropriate NTFS permissions (if the Web Folder is on an NTFS volume) to view or modify files.

Issues in accessing files on the internet

Resource Locking

lost update problem

Resource Management

view files lists

copy

move

delete

Document Properties

Versioning

not yet supported

Configuring Your server for WebDAV

Server Setup

Microsoft Internet Information Server 4.0 and FrontPage 98

Microsoft Internet Information Server 4.0 (requires Service Pack 4) and FrontPage 2000

Microsoft Internet Information Server 4.0 (requires Service Pack 4) and Office 2000 Server Extensions

Apache Web Server 1.2 and FrontPage 2000

Netscape Enterprise Server 3.0 and FrontPage 2000

Netscape FastTrack Server 2.0 and FrontPage 2000

O'Reilly WebSite 1.2 and FrontPage 2000

Stronghold Apache-SSL Web Server 2.0 and FrontPage 2000

Microsoft Internet Information Server 5.0

Web Folders

Directly accessible in browser on systems with Web folders support

Figure 5:Screen shot of IE 5.0 browsing

Network places in 2000

Install

Through IE 5.0 add on components or Office 2000

Security

Creating Your own WebDAV requests

Since WebDAV is a Extension to HTTP it is simple to

Using XMLHTTPRequest object

See Chapter 14 for info on this Component

VBScript

1

2

3

4

5

6

7

8

9

10

What You Need

The Example

Retrieving and Saving a file

Client page

1

2

3

4

5

6

7

8

9

10

XML Request Structure

The general structure of WebDAV requests follows the format of HTTP and is comprised of the following three components:

Method

States the method (described previously) to be executed by the client.

Headers

Describe instructions about how the task is to be completed.

A body (optional).

Defines the data used in the instruction, or additional instructions, about how the method is to be executed.  

The WebDAV Protocol

Options, Head, and Trace

Primarily used by applications for discovering and tracking server support and network behavior.

Get.

Retrieves documents.

Put and Post.

Submits documents to the server.

Delete

Destroys resources or collections. <