1 / 12

Chapter 4

Chapter 4. Working with Files in Your E-Commerce Application. Objectives: Working with Files in E-Commerce Application. How to use #Include file in ASP page. Redirect a customer to a new ASP page file. Use File Access Component to store customer information in a text file.

nellis
Download Presentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Working with Files in Your E-Commerce Application Objectives: • Working with Files in E-Commerce Application. • How to use #Include file in ASP page. • Redirect a customer to a new ASP page file. • Use File Access Component to store customer information in a text file.

  2. Including files in an ASP Page • Can be included using server-side #INCLUDE directive (used with ASP & HTML files). • Reason to include files: • To add same content to a number of pages at your website. • When you need to use a standard set of functions and procedures within multiple ASP pages. • Two forms of the directive: • <!-- #INCLUDE FILE=“somefile.ASP” --> • <!-- #INCLUDE VIRTUAL=“somefile.ASP” --> • The files can be included dynamically.

  3. Using File Redirection • The Request object has a method called Redirect to automatically redirect a customer to new file. • You can pass query string variables with redirect method but not TARGET attribute (redirecting to particular window/frame). • Not all browser support this.

  4. Don’t Use Redirect Method • Reasons: • Place more strain on your Web server bcoz it forces the browser to retrieve two pages instead of one. • Redirects aren’t fully supported by all browsers. Will get the message like:302: Object has moved. • Instead use Response.End

  5. Using the File Access Components • File Access Components are used to create and read text files. • Used to record information from HTML forms of Web Site.

  6. Objects of File Access Components • FileSystemObject – Includes all the basic methods for working with the file system. • TextStream – Used for reading & writing to a text file. • File – Represents an individual file. • Folder– Represent a file folder (a directory). • Drive- Represents a disk drive or network share.

  7. TextStream Object • CreateTextFile() method of FileSytemObject object is used to create text file and return reference to the TextStream Object. • It has 3 parameters of which one is compulsory and two are optional. They are: • FileSpecifier – Required parameter that specifies the path of the file to create. • Overwrite – Optional, by default value is TRUE. • Unicode-Optional, By default is FALSE. Indicates file using the ASCII character set should be created.

  8. Three Methods of TextStream used to write a text file: • Write(string)- Writes a string to text file. • WriteLine(String)- Writes a string to text file and appends a newline character. String argument is optional. • WriteBlankLines(lines) – Writes indicated number of blank lines to the text file.

  9. Reading a Text File • The four properties of FileSystemObjext used while reading are: • AtEndOfLine-New line character is detected. Default value is TRUE. • AtEndOfStream-Indicates the end of the text file is reached. • Column-This property indicates the current character position in a line. • Line-Indicates a current Line in a file.

  10. Contd….. • The four objects of TextStream object used to read a text file are: • Read(character)- Reads specified number of characters from the text file. • ReadLine-Reads single line from the text file. • ReadAll()- Reads entire content of the text file. • Skip(character)- Skips specified number of characters. • SkipLine- Skips one line in text file.

  11. Opening the Text File • The file must be opened before read from or write into it. • The following are the arguments used with OpenTextFile() method. • FileSpecifier-Required, specifies the path of the file to be open. • IOMode-Optional. Indicate file to be opened is to read/write/append. (1-R, 2-W,8-A). • Format-Optional. Specifies format of the file. By default it is ASCII.

  12. Managing Text Files • Methods of FileSystemObject to manage file are: • CopyFile() • MoveFile() • DeleteFile() • FileExists() • Display the files in the folder use FileSystemObject & Folder object.

More Related