sub GetOneFolder(PersonalPath)
set objFileSystem=server.CreateObject("scripting.filesystemobject")
PersonalPath=Server.MapPath (PersonalPath)
if trim(PersonalPath)<>"" and objFileSystem.FolderExists(PersonalPath) then
Set f = objFileSystem.GetFolder(PersonalPath)
strParentFolder = f.ParentFolder
set f=nothing
set oSubFolder=objFilesystem.GetFolder(PersonalPath).SubFolders
set oFiles=objFilesystem.GetFolder(PersonalPath).files
for each FileItem in oFiles
str = str& "<option value='"& UnMappath(fileitem.path) &"'"&">" & fileitem.name &" "&formatnumber(fileitem.size/1000,"2",-1,-1)&"Kb "& " "&fileitem.DateLastModified &"<BR>"
next
else
Set f = objFileSystem.GetFile(PersonalPath)
strParentFolder = f.ParentFolder
set f=nothing
set objFileSystem=nothing
response.redirect "FileManager.asp?errmsg=1&nf="& UnMappath(strParentFolder)
end if
set objFileSystem=nothing
end sub
Private function getParentFolder(byval strPath)
set objFileSystem=server.CreateObject("scripting.filesystemobject")
strPath=Server.MapPath (strPath)
if trim(strPath)<>"" and objFileSystem.FileExists(strPath) then
Set f = objFileSystem.GetFile(strPath)
strParentFolder = f.ParentFolder
getParentFolder=UnMappath(strParentFolder)
set f=nothing
else
getParentFolder=RootDir
end if
end function
sub DeleteFiles(PersonalPath)
strFilePath=trim(PersonalPath)
PersonalPath=Server.Mappath(PersonalPath)
dim fs
Set fs = server.CreateObject("Scripting.FileSystemObject")
if trim(PersonalPath)<>"" and fs.FileExists(PersonalPath) then
fs.DeleteFile PersonalPath
oConn.execute "Delete tblFile where FilePath ='"& strFilePath &"' or FilePath ='"& ".."&strFilePath &"' or FilePath ='"& "../"&strFilePath &"'"
elseif trim(PersonalPath)<>"" and fs.FolderExists(PersonalPath) then
fs.DeleteFolder PersonalPath
strFilePath=strFilePath&"/"
oConn.execute "Delete tblFile where (FilePath like '%"& strFilePath &"%') and (FilePath<>'"& strFilePath &"')"
end if
set fs=nothing
end sub
sub RenameFiles(PersonalPath, NewName)
strFilePath=PersonalPath
strNewDir = ".."&getParentFolder(strFilePath)
PersonalPath=Server.Mappath(strFilePath)
dim fs
Set fs = server.CreateObject("Scripting.FileSystemObject")
if trim(PersonalPath)<>"" and fs.FileExists(PersonalPath) then
Set f = fs.GetFile(PersonalPath)
f.name = NewName
set f=nothing
oConn.execute "update tblFile set FilePath='"& strNewDir&"/"&NewName &"' where FilePath ='"& strFilePath &"' or FilePath='.."&strFilePath &"'"
elseif trim(PersonalPath)<>"" and fs.FolderExists(PersonalPath) then
Set f = fs.GetFolder(PersonalPath)
f.name = NewName
set f=nothing
end if
set fs=nothing
end sub
sub CreatDir(PersonalPath)
PersonalPath=Server.Mappath(PersonalPath)
dim fs
Set fs = server.CreateObject("Scripting.FileSystemObject")
if trim(PersonalPath)<>"" and fs.FolderExists(PersonalPath) then
response.redirect "FileManager.asp?errmsg=2&nf="& currentfolder
else
fs.CreateFolder PersonalPath
end if
set fs=nothing
end sub
sub MakeFiles(PersonalPath)
PersonalPath=Server.Mappath(PersonalPath)
dim fs
Set fs = server.CreateObject("Scripting.FileSystemObject")
if trim(PersonalPath)<>"" and fs.FileExists(PersonalPath) then
response.redirect "FileManager.asp?errmsg=3&nf="& currentfolder
else
fs.CreateTextFile PersonalPath
end if
set fs=nothing
end sub
Private Function UnMappath(byVal FullPath)
'take a mappath-ed directory and make it virtual
dim root, tmp1, tmp2
fullpath=lcase(fullpath)
root = lcase(server.mappath("/"))
'FullPath = FullPath
tmp1 = Replace(fullPath, root, "")
tmp2 = Replace(tmp1, "\", "/")
'if not right(tmp2, 1) = "/" then tmp2 = tmp2 & "/"
UnMappath = Trim(tmp2)
End Function
sub CheckRootDir(PersonalPath)
PersonalPath=Server.Mappath(PersonalPath)
Set fs = server.CreateObject("Scripting.FileSystemObject")
if trim(PersonalPath)<>"" and fs.FolderExists(PersonalPath) then
else
fs.CreateFolder PersonalPath
end if
set fs=nothing
end sub
%>