AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=179&pId=-1
Creating a File Explorer
page
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 31206/ 73

Introduction

Creating a File Explorer in ASP

 

Published 1/13/02 - For Classic ASP

Introduction

The FileSystemObject is a very comprehensive set of classes that allow for very detailed navigation of the file system. To demonstate this, I have created a small file browser, which I will demonstrate the creation of in this article.

FileSystemObject

FileSystemObject

The core of this application is the FileSystemObject (FSO) object. The FSO contains all the tools needed for browsing directories, accessing files, editing files etc. This article isn't an introduction to the FSO.

The folder view

The folder's pane has to do several things -

  • List folder names with links to the folders.

  • Have the ability to view files in those folders (through the files frame).

  • Be able to create new folders.

  • Be able to modify folders.

  • Show general information about the folders.

  • Show the 'Up one level...' if it is not a root folder.

  • Show all other drives on the computer.

<%
If Len(Request.QueryString("drive")) Then
set objDrive = objFSO.GetDrive(Request.QueryString("drive"))
Else
set objDrive = objFSO.GetDrive("d:")
End If

Dim colFolder
Dim objcolFolders
If Len(Request.QueryString("folder")) Then
set objcolFolders = objFSO.GetFolder(Request.QueryString("folder"))
set colFolder = objColFolders.SubFolders
Else
Set objcolFolders = objFSO.GetFolder(objDrive.Driveletter & ":\domains")
set colFolder = objcolFolders.subfolders
End If
%>

This code attained the drive and folder that you wanted to access, this meant that you could just change two properties (1 if you inputted the whole path) to show the entire listing. It also specified default values.

<%
Dim objParent
If Not objcolFolders.Path = objDrive.Driveletter & ":\domains" Then
Set objParent = objcolFolders.ParentFolder
Response.Write("<a href=folders.asp?folder=" & objParent.Path & " target=folders>..Up one level</a>")
End If
%>

<%
Dim objSubFoldas
Dim objsubfoldas2
For each folda in colFolder
Response.Write("Edited listing")
Next
%>

These two block incorporate the ...Up one level and the entire listing (I edited that because it was too long).

 <%
For intCode = 65 To 90
letter = Chr(intCode)
If objFSO.DriveExists(letter) Then
Response.Write("<option value=" & letter & ">" & letter & "</option>")
End If
Next
%>

This looped through all of the drive letters possible (A (65)  - Z (90)) and checked for their existence before showing the option to display them.

The 'View' link, was set to link to files.asp?folder=[current folder].

The New Folder and 'More...' links were set to a file called morefolders.asp. On that page are a list of actions that the user can perform.

Files

Files

The files view is supposed to have the same functionality as the folders view -

  • Show all files in the current directory
  • Edit, delete and other options.
  • Be able to create files

All of these functions were attained in much the same way as the folders view -

<%
For each objFile in objColFolders.Files
Response.Write("Edited Listing")
Next
%>

This time it's using the Files collection.

Security

Security

You're probably thinking - "What about security in an application like this?" Security isn't really an issue, you can only access what the user - IUSR_[Computer Name] has access to. When your entire computer is using the NTFS file system then windows will provide the security that you need. Users may have read access to most files, but write, edit, erase etc. will be disabled. If you want it to do more than this, then just add some Windows Security measures.

However, the real problem comes in with ASP.NET. So if you decide to convert this to ASP.NET - use impersonation!

Download

Download

You can download the entire application here. Be sure to read the readme file.


Product Spotlight
Product Spotlight 

©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-12-02 8:14:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search