Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Asp Folder in ASP

Asp Folder in ASP

In Classic ASP, working with folders is done via the FileSystemObject (FSO). You can create, delete, check existence, and list folders and their contents.


Using FSO to Work with Folders in ASP


1. Create the FileSystemObject

<%Dim fsoSet fso = Server.CreateObject("Scripting.FileSystemObject")%>

2. Check if a Folder Exists

Dim folderPathfolderPath = Server.MapPath("uploads")If fso.FolderExists(folderPath) Then    Response.Write "Folder exists."Else    Response.Write "Folder does not exist."End If

3. Create a Folder

Dim folderPathfolderPath = Server.MapPath("uploads")If Not fso.FolderExists(folderPath) Then    fso.CreateFolder(folderPath)    Response.Write "Folder created."Else    Response.Write "Folder already exists."End If

4. Delete a Folder

Dim folderPathfolderPath = Server.MapPath("oldfolder")If fso.FolderExists(folderPath) Then    fso.DeleteFolder(folderPath)    Response.Write "Folder deleted."Else    Response.Write "Folder does not exist."End If

5. Get Folder Properties

Dim folderPath, folderfolderPath = Server.MapPath("uploads")If fso.FolderExists(folderPath) Then    Set folder = fso.GetFolder(folderPath)    Response.Write "Folder Name: " & folder.Name & "<br>"    Response.Write "Date Created: " & folder.DateCreated & "<br>"    Response.Write "Date Last Modified: " & folder.DateLastModified & "<br>"    Response.Write "Size (bytes): " & folder.Size & "<br>"    Response.Write "Parent Folder: " & folder.ParentFolder & "<br>"    Set folder = NothingElse    Response.Write "Folder not found."End If

6. List Files in a Folder

Dim folderPath, folder, filefolderPath = Server.MapPath("uploads")If fso.FolderExists(folderPath) Then    Set folder = fso.GetFolder(folderPath)        For Each file In folder.Files        Response.Write "File: " & file.Name & "<br>"    Next        Set folder = NothingElse    Response.Write "Folder not found."End If

7. List Subfolders in a Folder

Dim folderPath, folder, subfolderfolderPath = Server.MapPath("uploads")If fso.FolderExists(folderPath) Then    Set folder = fso.GetFolder(folderPath)        For Each subfolder In folder.SubFolders        Response.Write "Subfolder: " & subfolder.Name & "<br>"    Next        Set folder = NothingElse    Response.Write "Folder not found."End If

Clean up:

Set fso = Nothing

Notes:

  • Always use Server.MapPath to convert a virtual path (URL path) to a physical path on the server.

  • Be cautious when deleting folders — ensure you are not deleting important data.

  • Folder size is cumulative size of all files in the folder.


If you want me to help with recursive folder listing, file upload to folder, or error handling with folders, just say!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql