rarFile = "1RAR"
newFolder="D:\"
Shell AppPath & IIf(Right(AppPath, 1) = "\", "", "\") & "unrar x " & rarFile & " " & newFolder
给你个VB遍历文件夹的代码吧
Private
Declare
Function
FindFirstFile
Lib
"kernel32"
Alias
"FindFirstFileA"
(ByVal
lpFileName
As
String,
lpFindFileData
As
WIN32_FIND_DATA)
As
Long
'查找下一个文件的API
Private
Declare
Function
FindNextFile
Lib
"kernel32"
Alias
"FindNextFileA"
(ByVal
hFindFile
As
Long,
lpFindFileData
As
WIN32_FIND_DATA)
As
Long
'获取文件属性的API
Private
Declare
Function
GetFileAttributes
Lib
"kernel32"
Alias
"GetFileAttributesA"
(ByVal
lpFileName
As
String)
As
Long
'关闭查找文件的API
Private
Declare
Function
FindClose
Lib
"kernel32"
(ByVal
hFindFile
As
Long)
As
Long
Const
MAX_PATH
=
260
Const
MAXDWORD
=
&HFFFF
Const
FILE_ATTRIBUTE_DIRECTORY
=
&H10
Private
Type
FILETIME
dwLowDateTime
As
Long
dwHighDateTime
As
Long
End
Type
Dim
tempstr
As
String
'定义类(用于查找文件)
Private
Type
WIN32_FIND_DATA
dwFileAttributes
As
Long
ftCreationTime
As
FILETIME
ftLastACCESSTime
As
FILETIME
ftLastWriteTime
As
FILETIME
nFileSizeHigh
As
Long
nFileSizeLow
As
Long
dwReserved0
As
Long
dwReserved1
As
Long
cFileName
As
String
MAX_PATH
cAlternate
As
String
14
End
Type
Dim
filecount
As
Integer
Dim
dirs()
As
String
Dim
curr
As
Long
Dim
ss()
As
String
Private
Sub
Command1_Click()
tempstr
=
"c:"
searchdir
tempstr
filecount
=
0
End
Sub
Public
Function
searchdir(path
As
String)
Dim
WFD
As
WIN32_FIND_DATA
Dim
i
As
Long
Dim
temp
As
String
Dim
h
As
Long
Dim
zhaodao
As
Long
Dim
iindex
As
Integer
Dim
dirs()
As
String
Dim
l
As
Long
zhaodao
=
1
h
=
FindFirstFile(path
&
"\",
WFD)
If
h
<>
-1
Then
While
zhaodao
zhaodao
=
1
temp
=
Left(WFDcFileName,
InStr(WFDcFileName,
Chr$(0))
-
1)
If
temp
<>
""
And
temp
<>
""
Then
If
WFDdwFileAttributes
And
vbDirectory
Then
ReDim
Preserve
dirs(iindex)
dirs(iindex)
=
path
&
"\"
&
temp
iindex
=
iindex
+
1
ReDim
Preserve
ss(filecount)
ss(filecount)
=
path
&
"\"
&
temp
filecount
=
filecount
+
1
End
If
End
If
zhaodao
=
FindNextFile(h,
WFD)
Wend
End
If
FindClose
(h)
If
iindex
>
0
Then
For
i
=
0
To
iindex
-
1
Call
searchdir(dirs(i))
Next
i
End
If
End
Function
不是找不到text1text的文件,而是找不到rarexe。
你要把C:\Program Files\WinRAR下的Rarexe复制到已经生成应用程序的目录下。如果要在调试模式下运行,就要复制到VB的安装目录下(就是VB6EXE所在的目录)。
以上就是关于VB中奖UnRAR.exe将RAR解压到指定文件夹全部的内容,包括:VB中奖UnRAR.exe将RAR解压到指定文件夹、VB获取文件夹路径、vb中winrar应用,程序解压缩等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)