I am trying to convert the following ASP VBScript to C# to use on our company's new ASP.Net 3.5 web site.
Can anyone help convert the following code .... Much appreciated.
Rob
Code Sample ...
<ul> <% ' List Folder(s) Content(s) Dim dir dir = Trim(request("dir")) ListFolderContents(Server.MapPath("/" & dir & "/")) %> </ul> <% 'Scrit to List content(s) of folder(s) sub ListFolderContents(path) dim fs, folder, file, item, url set fs = CreateObject("Scripting.FileSystemObject") set folder = fs.GetFolder(path) 'Original code below -------------- 'Display the target folder and info. 'Response.Write("<li><b>" & folder.Name & "</b> - " _ '& folder.Files.Count & " files, ") Response.Write("<br><li><b>" & folder.Name & "</b>") Response.Write("<ul>" & vbCrLf) 'Original code below -------------- 'if folder.SubFolders.Count >0 then 'Response.Write(folder.SubFolders.Count & " directories, ") 'end if 'Response.Write(Round(folder.Size / 1024) & " KB total." _ '& vbCrLf) 'Response.Write("<ul>" & vbCrLf)
'Display a list of sub folders. for each item in folder.SubFolders ListFolderContents(item.Path) next
'Display a list of files. for each item in folder.Files url = MapURL(item.path) Response.Write("<li><a href=""" & url & """>" & Replace(item.Name, "_", " ") & "</a> - " _ & item.Size & " bytes, " _ & "</li>" & vbCrLf) 'Original code below -------------- '& "modified on " & item.DateLastModified & "." _ '& "</li>" & vbCrLf) '& item.Size & " bytes. " _ '& "</li>" & vbCrLf) next Response.Write("</ul>" & vbCrLf) Response.Write("</li>" & vbCrLf) end sub 'Convert a physical file path to a URL for hypertext links. function MapURL(path) dim rootPath, url rootPath = Server.MapPath("/") url = Right(path, Len(path) - Len(rootPath)) MapURL = Replace(url, "\", "/") end function %>