'************************************** ' Name: General File System Object Funct ' ions ' Description:These are few general func ' tions i have written related to File Sys ' tem Object: - Check if a SPECIFIC folder exists - Check if A SPECIFIC file EXISTS in A SPECIFIC folder - Create A SPECIFIC folder - Delete A SPECIFIC folder - Delete ALL FILES in a SPECIFIC folder - Delete A SPECIFIC file in A SPECIFIC folder Your comments and highly appreciated. And finally thanks to all coders here at PSC for sharing their knowledge and their work! ' By: Vladimir Miho (from psc cd) ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** <% '======================================= ' ==========================' 'Check if a SPECIFIC folder exists ' ' 'Input: ' ' - Path: the path where the folder is ' suppose to be ' ' - FolderName: the name of the folder ' you want to check for' 'Output: ' ' - True: if the folder exists ' ' ' - False: if the folder does not exist ' ' '======================================= ' ==========================' Function CheckIfFolderExists(byVal Path, byVal FolderName) Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") dim FullPath FullPath = Path & FolderName if objFSO.FolderExists(FullPath) then CheckIfFolderExists = true else CheckIfFolderExists = false end if set objFSO = nothing End Function '--------------------------------------- ' --------------------------' '======================================= ' ==========================' 'Checks if A SPECIFIC file EXISTS in A S ' PECIFIC folder ' 'Input: ' ' - FolderPath: the path of the folder ' ' ' - FileName: the name of the file you ' want to check for' 'Output: ' ' - True: if the file exists ' ' - False: if the file does not exist ' ' '======================================= ' ==========================' Function CheckIfFileExists(byVal FolderPath, byVal FileName) CheckIfFileExists = false Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") set objFolder = objFSO.GetFolder(FolderPath) for each file in objFolder.files if Lcase(file.name) = Trim(LCase(Filename)) then CheckIfFileExists = true end if next set objFSO = nothing End Function '--------------------------------------- ' --------------------------' '======================================= ' ==========================' 'Creates A SPECIFIC folder ' 'Input: ' ' - Path: path where you want to create ' the folder ' ' - NewFolderName: the name of the new ' folder ' 'Output: ' ' - True: if the folder is created succ ' essfully ' ' - False: if the folder creation faile ' d ' '======================================= ' ==========================' Function CreateNewFolder(byVal Path, byVal NewFolderName) Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") dim FullPath FullPath = Path & NewFolderName if not objFSO.FolderExists(FullPath) then objFSO.CreateFolder(FullPath) CreateNewFolder = true else CreateNewFolder = false end if set objFSO = nothing End Function '--------------------------------------- ' --------------------------' '======================================= ' ==========================' 'Deletes A SPECIFIC folder ' 'Input: ' ' - Path: path where the folder is ' ' ' - FolderName: the name of the folder ' you want to delete' 'Output: ' ' - True: if the folder is deleted ' ' ' - False: if the folder could not be d ' eleted ' '======================================= ' ==========================' Function DeleteFolder(byVal Path, byVal FolderName) Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") dim FullPath FullPath = Path & FolderName if objFSO.FolderExists(FullPath) then objFSO.DeleteFolder(FullPath) DeleteFolder = true else DeleteFolder = false end if set objFSO = nothing End Function '--------------------------------------- ' --------------------------' '======================================= ' ==========================' 'Deletes ALL FILES in a SPECIFIC folder ' ' 'Input: ' ' - Path: path where the folder is ' ' ' - FolderName: the name of the folder ' where the files you ' ' want to delete are ' 'Output: none ' '======================================= ' ==========================' Function DeleteFilesInFolder(byVal Path, byVal FolderName) Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") dim FullPath FullPath = Path & FolderName set objFolder = objFSO.GetFolder(FullPath) for each file in objFolder.files file.delete(true) next set objFSO = nothing End Function '--------------------------------------- ' --------------------------' '======================================= ' ==========================' 'Deletes A SPECIFIC file in A SPECIFIC f ' older ' 'Input: ' ' - Path: path where the folder is ' ' ' - FolderName: the name of the folder ' where the file you' ' want to delete is ' ' - FileName: name of the file you want ' to delete ' 'Output: ' ' - True: if the file is deleted ' ' - False: if the file could not be del ' eted ' '======================================= ' ==========================' Function DeleteFileInFolder(byVal Path, byVal FolderName, byVal FileName) DeleteFileInFolder = False Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") dim FullPath FullPath = Path & FolderName set objFolder = objFSO.GetFolder(FullPath) for each file in objFolder.files if Lcase(file.name) = Trim(LCase(Filename)) then file.delete(true) DeleteFileInFolder = True end if next set objFSO = nothing End Function '--------------------------------------- ' --------------------------' %>