in ASP, you can use Scripting.FileSystemObject component, for example<%
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")Function ListFile(f)
Dim f1, fc, s
Set fc = f.Files
For Each f1 in fc
s = s & f1.name & ","
s = s & f1.Size & ","
s = s & f1.Path
s = s & "<BR>"
Next
ListFile = s
End Function
Function ShowFolderList(folderspec)
Dim f, f1, fc, s
Set f = fso.GetFolder(folderspec)
s = ListFile(f)
Set fc = f.SubFolders
For Each f1 in fc
s = s & ShowFolderList(f1.Path)
Next
ShowFolderList = s
End FunctionResponse.Write ShowFolderList(Server.MapPath("/testcode"))
%>
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")Function ListFile(f)
Dim f1, fc, s
Set fc = f.Files
For Each f1 in fc
s = s & f1.name & ","
s = s & f1.Size & ","
s = s & f1.Path
s = s & "<BR>"
Next
ListFile = s
End Function
Function ShowFolderList(folderspec)
Dim f, f1, fc, s
Set f = fso.GetFolder(folderspec)
s = ListFile(f)
Set fc = f.SubFolders
For Each f1 in fc
s = s & ShowFolderList(f1.Path)
Next
ShowFolderList = s
End FunctionResponse.Write ShowFolderList(Server.MapPath("/testcode"))
%>
解决方案 »
- java 解析 xml文件, 多层节点读取,请高手帮忙啊 !我要解析的XML已经在下面
- 关于DAO的一个问题
- WAP网页在手机UC浏览器中显示的问题
- 求救:java.lang.IllegalArgumentException: bad date header: 'n 2007 01:52:06 GMT'
- 我要用JAVA的框架写.NET程序,怎么做
- 领导要做报表,并形成产品! 我现在很郁闷,该如何开发呢?
- 下拉列框
- 哪有整合linux下的apache和tomcat的.so文件下载
- 求 UML 设计工具下载地址,谢谢
- 新手上路,高手多多提拔阿。请问servlet和JSP有什么区别
- 编译java文件的时候提示,找不到“import javax.servlet.ServletConfig”
- JAVAMAIL发出去的附件名字是乱码,??
<%@ page import ="java.util.*,java.io.*"%><%
StringBuffer jspConcent = new StringBuffer() ;
String sSrcName="c:\\java\\test.txt";
String sPath = "c:\\java" ;
File objFile = new File(sPath) ;
if (!objFile.isDirectory())
out.print("Java不是目录!") ;
else{
String[] aFiles = objFile.list() ;
if (aFiles!=null){
for(int i=0;i<aFiles.length;i++)
out.print("<br>"+aFiles[i]) ;
}
File[] objFiles = objFile.listFiles() ;
if (objFiles!=null){
for(int i=0;i<objFiles.length;i++)
if (objFiles[i].isDirectory()){
out.print("<br>"+objFiles[i].getPath()) ;
jspConcent.append(objFiles[i].getPath()+"\n") ;
}else{
out.print("<br>file=="+objFiles[i].getPath()) ;
if (objFiles[i].delete())
out.print("<br>"+objFiles[i].getPath()+"被删除!") ;
}
} try
{
PrintWriter pw = new PrintWriter(new FileWriter(sSrcName, false), true);
pw.println(jspConcent.toString());
}
catch (Exception e)
{
System.out.println("error");
}
}
%>