Directory Listesi

Directory Listesi (tr) FSO kullanılarak klasörünüzdeki dosyaları ve klasörleri boyutları ile listeleme yapan bir kod.Bu kodları herhangi bir isimde .asp dosyası olarak kayıt edin ve çalıştırın.******************************************************************"|==================================|" "| PsyChaos - Directory List v1.0b |" "| Coded By PsyChaos |" "| A.K.A Semih Turna |" "| 04.04.2004 14:52 |" "|==================================|" Class DL Private objFSO, objFolder Private rsDirectory Private Msg Public strLocation Private Sub Class_Initialize() Const adInteger = 3 Const adVarChar = 200 Const adBoolean = 11 Const adDBTimeStamp = 135 Set objFSO = Server.CreateObject("Scripting.FileSystemObject" ) Set rsDirectory = Server.CreateObject("ADODB.RecordSet" ) With rsDirectory .Fields.AppEnd "Name" , adVarChar, 50 .Fields.AppEnd "Type" , adBoolean .Fields.AppEnd "Location" , adVarChar, 100 .Fields.AppEnd "Size" , adInteger .Fields.AppEnd "DateLastModified" , adDBTimeStamp .Open End With End Sub Private Sub Class_Terminate() If IsObject(objFSO) Then Set objFSO = Nothing If IsObject(rsDirectory) Then rsDirectory.Close : Set rsDirectory = Nothing End Sub Public Sub AddItem If objFSO.FolderExists(strLocation) = False Then ErrMsg "Girmiş Olduğunuz " & strLocation &" Adlı Yol Bulunamadı!" Else Set objFolder = objFSO.GetFolder(strLocation) For Each strFolder In objFolder.SubFolders With rsDirectory .AddNew .Fields("Name" ) = strFolder.Name .Fields("Type" ) = 0 .Fields("Location" ) = EditUrl(Session("Path" ) &"" & strFolder.Name) .Fields("Size" ) = strFolder.Size .Fields("DateLastModified" ) = strFolder.DateLastModified .Update End With Next For Each strFile In objFolder.Files With rsDirectory .AddNew .Fields("Name" ) = strFile.Name .Fields("Type" ) = 1 .Fields("Location" ) = EditUrl(Session("Path" ) &"" & strFile.Name) .Fields("Size" ) = strFile.Size .Fields("DateLastModified" ) = strFile.DateLastModified .Update End With Next End If End Sub Public Sub DirectoryList If objFSO.FolderExists(strLocation) = True Then If objFolder.SubFolders.Count> 0 Then strTotalFolder = objFolder.SubFolders.Count strTotalFile = objFolder.Files.Count strPath = objFolder.ShortPath strFolderSize = FileSize(objFolder.Size) End If If rsDirectory.Eof Then ErrMsg "Kayıt Bulunmamaktadır!" Else With Response .Write "" & vbCrlf .Write " " & vbCrlf .Write " " & vbCrlf .Write " " & vbCrlf .Write "

#" & vbCrlf .Write " " & vbCrlf .Write " Ad" & vbCrlf .Write " " & vbCrlf .Write "

Boyut" & vbCrlf .Write " " & vbCrlf .Write "

Değiştirilme Tarihi" & vbCrlf .Write " " & vbCrlf .Write " Üst Klasör" rsDirectory.Movefirst Do While Not rsDirectory.Eof If rsDirectory.Fields("Type" ).Value = 0 Then strImage = "" strName = "" & rsDirectory.Fields("Name" ).Value &"" Else strImage = "" strName = "" & rsDirectory.Fields("Name" ).Value &"" End If .Write " " & vbCrlf .Write "

" & strImage &"" & vbCrlf .Write " " & strName &"" & vbCrlf .Write " " & vbCrlf .Write "

" & FileSize(rsDirectory.Fields("Size" ).Value) &"" & vbCrlf .Write " " & vbCrlf .Write "

" & rsDirectory.Fields("DateLastModified" ).Value &"" & vbCrlf .Write " " & vbCrlf rsDirectory.Movenext Loop .Write " " & vbCrlf .Write " " & vbCrlf .Write "

Bunulunduğunuz klasör " & strPath &" - Bu klasörde " & strTotalFile &" dosya, " & strTotalFolder &" alt klasör bulunmaktadır.Bulunduğunuz klasörün boyutu " & strFolderSize &"" & vbCrlf .Write " " & vbCrlf .Write " " & vbCrlf .Write "" & vbCrlf End With End If End Sub Private Function FileSize(ItemSize) If ItemSize>= 1073741824 Then ItemSize = FormatNumber((ItemSize/1073741824),2) &" GB" ElseIf ItemSize>= 1048576 Then ItemSize = FormatNumber((ItemSize/1048576),2) &" MB" ElseIf ItemSize>= 1024 Then ItemSize = FormatNumber((ItemSize/1024),2) &" KB" ElseIf ItemSize>= 0 Then ItemSize = ItemSize &" byte" Else ItemSize = "0 byte" End If FileSize = ItemSize End Function Private Function EditUrl(Url) If InStr(1,Url, "\" ,1) 0 Then Url = Replace(Url,"\" ,"" ) EditUrl = Url End Function Public Sub ErrMsg(Msg) Response.Write "Hata : " & Msg &"" & vbCrlf End Sub End Class Session("Path" ) = Replace(Request.QueryString("Path" ),"/" ,"" ) If Session("Path" ) = "" Then Response.Redirect "?Path=." If Session("Path" ) = "." Then Response.Redirect "?Path=.." If Session("Path" ) = ".." Then Session("Path" ) = Session("Path" ) &"" Set DList = New DL DList.strLocation = Server.MapPath(Session("Path" )) DList.AddItem DList.DirectoryList Set DList = Nothing With Response .Write "" & vbCrlf .Write "" .Write "PsyChaos - Directory List v1.0bCoded By PsyChaos" .Write "" End With %>

Döküman Arama

Başlık :

Kapat