ASP file Operations Tutorial

Source: Internet
Author: User

ASP files
The interaction of all files in ASP is through the file system component, which is included with IIS. It contains a number of objects that give you a window to the system's file system. Some of the more important objects include:


File System objects
File objects
Folder objects
Before you can get a second and a third object, we list above the magnificent Dad Master File system objects you must create (film Services Co). Through this overall goal, everything is accessible in the file system component.

File objects created by ASP technology
In order to create the film services division you simply create an object reference to it like any other object in the ASP. Examine the lessons of our ASP objects as soon as possible.

In the following example, we create a file object and destroy it.

<%
Dim Myfso
Set Myfso = Server.CreateObject _
("Scripting.FileSystemObject")
Set Myfso = Nothing
%>

Working with File objects
The files required to retrieve a relative or complete file path that you must know about in an ASP. In this example we will assume that a file exists "C:inetpub wwwroot 111cnASP firstscript.asp".

Myfo standing on my file object. This small script will get a file object and print out the name of the file used by the property.

<%
Dim myfso, myfo
Set Myfso = Server.CreateObject _
("Scripting.FileSystemObject") br> set Myfo = Myfso.getfile _
("c:inetpubwwwroot111cnaspfirstscript.asp"
Response.Write ("The filename:" & myfo.name)
Set myfo = Nothing
Set myfso = Nothing
%>< /p>

Used folder objects
to retrieve the folder object you must supply again the relative or complete directory path. If you follow us on how to run the ASP installation then you will have a folder located at 111cnASP "C:inetpub wwwroot 111cnASP". The

Myfoldero is standing in my folder object. This example is to borrow a previous lesson from an ASP component that will display a list of all files in the "111cnASP" folder. We will use the Name property again as the object of the folder and file.

<%
Dim myfso, Myfoldero
Set myfso = Server.CreateObject ("Scripting.FileSystemObject")
Set Myfolde RO = _
myfso.getfolder ("c:inetpubwwwroot111cnasp")

Response.Write ("Current folder is: ' & Myfoldero.name '

for each fileitem in Myfoldero.files
    Response.Write ("<br/& gt; & Fileitem.name)
Next
Set myfoldero = Nothing
Set myfso = Nothing
%>

If you have been with this tutorial beginning to end your browser will show such things when you execute the script.

The filename is:111cnasp
firtscript.asp
111cn.mdb
111cncomponent.asp
111cnemail.asp
111cnF orm.html
111cnget.asp
111cnpost.asp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.