구글와이드(336x280)_상단 2개


(영문) ASP Components - Tutorial ASP, ASP.NET

ASP Components

An ASP Server Component is a collection of code that has been made by Microsoft (advanced users can also create their own components), and included in IIS. With the use of ASP you can unlock the power of this pre-made code.
These objects can be used to do a ton of things, such as: an easy-to-use ad rotation service, an interface to a database, a means of manipulating files and much more.

Using ASP Components

Making use of Microsoft's ASP Components in your ASP programming will allow you to do so much with ASP that you'll be kicking yourself for not using components earlier. You can access these built in components by creating objects of them. See our previous lesson if you need a refresher on what ASP Objects are.
In this lesson we will be utilizing Microsoft's FileSystem Component to display all the files in our current directory. The first thing we need to do is to create a FileSystem object so we can use all the properties and methods that are in this component. Note: FSO stands for File System Object in this example.

tizagComponent.asp ASP Code:

<%
Dim myFSO
Set myFSO = _
Server.CreateObject("Scripting.FileSystemObject")
Set myFSO = nothing
%>

Accessing an ASP Component's Features

Once you have created an object of your desired component you can access all the methods and variables of that component. We have created an instance of the File System Component and stored it into myFSO. We need the folder that we're going to list all the files of and the GetFolder method of our FSO will do the job.
Using the same directory we decided to use back in the Running ASP lesson we are going to set the path of this FSO to "C:\Inetpub\wwwroot\tizagASP\", the same directory that "tizagComponent.asp" was saved in.

Updated tizagComponent.asp ASP Code:

<% Dim myFSO, myFolder
Set myFSO = _
Server.CreateObject("Scripting.FileSystemObject")
Set myFolder = _myFSO.GetFolder("C:\Inetpub\wwwroot\tizagASP")
Response.Write("Current folder is: " & myFolder.Name)
Set myFolder = nothing
Set myFSO = nothing
%>

Display:

Current folder is: tizagASP

Finishing Up

The last thing on our to-do list is to get access to the names of the files in our working directory. The Folder object contains a method that returns a collection of all the files in the current directory. The code for accessing this collection and displaying the filenames is in the example below.

Updated tizagComponent.asp ASP Code:

<%
Dim myFSO, myFolder
Set myFSO = _
Server.CreateObject("Scripting.FileSystemObject")
Set myFolder = _myFSO.GetFolder("C:\Inetpub\wwwroot\tizagASP")
Response.Write("Current folder is: " & myFolder.Name)

For Each fileItem In myFolder.Files     Response.Write("<br />" & fileItem.Name) Next
Set myFolder = nothing
Set myFSO = nothing
%>
If you have done every example in this ASP Tutorial your web page produced would look like this. Notice that the files are automatically sorted alphabetically!

Display:

firtscript.asp
tizagComponent.asp
tizagEmail.asp
tizagForm.html
tizagGet.asp
tizagPost.asp

null



바보들의 영문법 카페(클릭!!)

오늘의 메모....

시사평론-정론직필 다음 카페
http://cafe.daum.net/sisa-1

바보들의 영문법 다음 카페
http://cafe.daum.net/babo-edu/

티스토리 내 블로그
http://earthly.tistory.com/

내 블로그에 있는 모든 글들과 자료에 대한 펌과 링크는 무제한 허용됩니다.
(단, 내 블로그에 덧글쓰기가 차단된 자들에게는 펌, 트랙백, 핑백 등이 일체 허용되지 않음.)

그리고 내 블로그 최근글 목록을 제목별로 보시려면....
바로 아래에 있는 이전글 목록의 최근달을 클릭하시면 됩니다.
그러면 제목을 보고 편하게 글을 골라 보실 수 있습니다.

그리고 내 블로그내 글을 검색하시려면 아래 검색버튼을 이용하시면 됩니다.


가가챗창

flag_Visitors

free counters