Search Tools Links Login

Folder Management Functions (Create, Delete, Move etc...)


Functions to Create folder, Delete Folder, Move Folder, Copy Folder, Check if File Exists, and folder size in bytes

Original Author: snowboardr

Inputs

Server.MapPath() to get the current directory so you would run the Create Folder function Like so
CreateFolder(Server.MapPath(" est"))

Side Affects

DeleteFolder Will remove everything within that folder... and becarefull you dont delete the wrong directory.

Code

<%
'#######################################
'# Folder Management Functions
'# Written By Jason
'# '#####################################
'# Site San Diego
'# sitesd.com
'#######################################
Dim objFso
'# CREATE FOLDER
Function CreateFolder(fdirCRE)
Set objFso = CreateObject("Scripting.FileSystemObject")
If Not objFso.FolderExists(fdirCRE) Then
objFso.CreateFolder(fdirCRE)
Else
Exit Function
End If
set objFso = nothing
End Function

'# DELETE FOLDER
Function DeleteFolder(fdirDEL)
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFso.FolderExists(fdirDEL) Then
objFso.DeleteFolder(fdirDEL)
End If
set objFso = nothing
End Function

'# MOVE FOLDER
Function MoveFolder(fdirM1, fdirM2)
Set objFso = CreateObject("Scripting.FileSystemObject")
objFso.MoveFolder fdirM1, fdirM2
set objFso = nothing
End Function

'# COPY FOLDER
Function CopyFolder(fdirC1, fdirC2, fdirC3)
If fdirC3 = "" then fdirC3 = False
Set objFso = CreateObject("Scripting.FileSystemObject")
objFso.CopyFolder fdirC1, fdirC2, fdirC3
set objFso = nothing
End Function

'# CHECK IF FILE EXSISTS
Function FileHere(fdirHere)
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFso.FileExists(fdirHere) Then
FileHere = True
Else
FileHere = False
End If
set objFso = nothing
End Function



'# Folder Size
Function FolderSize(filespec)
  Set fso = CreateObject("Scripting.FileSystemObject")
  Dim fso, f, s
If fso.FolderExists(filespec) Then
  Set f = fso.GetFolder(filespec)
  s = f.size
  If s = "" then s = "0"
  Else
  s = "0"
End If
  FolderSize = CLNG(s)
  Set fso=nothing
End Function

%>

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 97 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.