File
file
=
new
File("D:\\mm")
File[]
files
=
file.listFiles(new
FilenameFilter()
{
public
boolean
accept(File
file,
String
fileName)
{
if(fileName.endsWith(".java")){
return
true
}
return
false
}
})
这就是获取D:mm目录下的.java文件
将生成的exe放入文件夹private
txtname()
as
string
'定义一个数组装入txt名称
dim
spath
as
string
sub
gettxtname(byval
spath
as
string,
byval
filter
as
string)
'这是获取指定文件夹下指定后缀名的文件名称的过程,装入数组txtname()中,spath就是这里写放txt的文件夹路径
dim
sdir
as
string
dim
sfilter()
as
string
dim
lngfilterindex
as
long
dim
lngindex
as
long
sfilter
=
split(filter,
",")
if
right(spath,
1)
<>
"\"
then
spath
=
spath
&
"\"
for
lngfilterindex
=
lbound(sfilter)
to
ubound(sfilter)
sdir
=
dir(spath
&
sfilter(lngfilterindex))
do
while
len(sdir)
>
0
lngfiles
=
lngfiles
+
1
redim
preserve
txtname(1
to
lngfiles)
txtname(lngfiles)
=
sdir
sdir
=
dir
loop
next
end
sub
private
sub
command1_click()
dim
i%
spath
=
app.path
&
"\"
call
gettxtname(spath,
"*.html")
for
i
=
1
to
ubound(txtname)
name
spath
&
txtname(i)
as
spath
&
left(txtname(i),
instr(txtname(i),
".")
-
1)
&
".pdf"
next
msgbox
"done!"
end
sub
使用js获取文件的后缀 有个不错的正则 大家可以借用下 具体如下 感兴趣的朋友可以参考下哈 希望对大家有所帮助正则得到后缀
复制代码 代码如下: lishixinzhi/Article/program/Java/Javascript/201311/25503
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)