
22/02/2008, 02:59
|
| | Fecha de Ingreso: julio-2006
Mensajes: 145
Antigüedad: 18 años, 9 meses Puntos: 0 | |
Convertir de asp a "jscript" Hola, tengo este codigo en asp que funciona :
<HTML>
<HEAD>
<% set fs = CreateObject("Scripting.FileSystemObject")
</HEAD>
<BODY>
<% function MapURL(path)
dim rootPath, url
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function %>
<% path = Server.MapPath("/Manuales/")
ListFolderContents(path)
%>
<% sub ListFolderContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
Response.Write("<li><b>" & folder.Name)
Response.Write("</li>")
Response.Write("<ul>" & vbCrLf)
ListFilesContents(path)
for each item in folder.SubFolders
ListFolderContents(item.Path)
next
Response.Write("</ul>" & vbCrLf)
end sub %>
<% sub ListFilesContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
for each item in folder.Files
url = MapURL(item.path)
Response.Write("<li><a href=""" & url & """>" & item.Name & "</a>" & "</li>")
next
end sub %>
</BODY>
</HTML> y me gustaria pasarlo a jscript.Estoy en ello :
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<% fso = new ActiveXObject("Scripting.FileSystemObject");
%>
</HEAD>
<BODY>
<% function MapURL(path)
{
var rootPath, url,longitud1,longitud2,longitudtotal,elpath;
elpath=path;
rootPath = Server.MapPath("/");
longitud1=elpath.length;
longitud2=rootPath.length;
longitudtotal=longitud1-longitud2;
url = elpath.substring(longitud1,longitudtotal);
MapURL = url.replace("\\", "/");
} %>
<% path = Server.MapPath("/Manuales/")
ListFolderContents(path)
%>
<% function ListFolderContents(path)
{
var fs, folder, file, item, url;
fs = new ActiveXObject("Scripting.FileSystemObject");
folder = fs.GetFolder(path);
Response.Write("<li><b>" & folder.Name);
Response.Write("</li>");
Response.Write("<ul>" + "vbCrLf");
ListFilesContents(path);
for (var f = new Enumerator(folder.SubFolders) ; !f.atEnd(); f.moveNext())
{
ListFolderContents(item.Path);
}
Response.Write("</ul>" + vbCrLf);
}%>
<% function ListFilesContents(path)
{
var fs, folder, file, item, url;
fs = new ActiveXObject("Scripting.FileSystemObject");
folder = fs.GetFolder(path);
for (var f=new Enumerator(folder.files) ; !f.atEnd(); f.moveNext())
{
var temporal=f.item();
url = MapURL(temporal.path);
Response.Write("<li><a href=" + url + ">" + f.item().Name + "</a></li>");
}
}%>
</BODY>
</HTML> me da errores, si alguien me pudiera ayuddar...Gracias! |