Public Function FileExists(sFullPath As String) As Boolean
Dim oFile As New Scripting.FileSystemObject
FileExists = oFile.FileExists(sFullPath)
End Function
Dim oFile As New Scripting.FileSystemObject
FileExists = oFile.FileExists(sFullPath)
End Function
解决方案 »
- 信息安全大赛
- vb如何通过ip查询所在地
- XP中打包的VB的exe文件,在windows 2003 上执行不了?怪事儿! 提示有文件注册失败
- 我用Vb用了Adodc控件和DataGrid编号程序,为啥到了别的机器不能用。
- ************关于vsview打印控件****************
- VB中有关集合的问题
- 十万火急,请问怎样可以改变无标题栏窗体大小?????????
- vb 中是不是没有回撤功能
- ###########有什么办法可以让一个程序随98启动自动运行,并且在msconfig里不显示??
- 一个简单问题:VB中的网格控件(如msflex等)都没有提供单元格编辑、显示复选框、组合框等,请问有什么方法可以实现?
- 请问datagrid控件如何通过ado来显示数据??
- 怎样判断Num lock\Caps lock\Scroll lock的状态
Dim fso As New FileSystemObject
Dim fld As FolderPrivate Sub Command1_Click()
Dim nDirs As Integer, nFiles As Integer, lSize As Long
Dim sDir As String, sSrchString As String
sDir = InputBox("Please enter the directory to search", _
"FileSystemObjects example", "C:\")
sSrchString = InputBox("Please enter the file name to search", _
"FileSystemObjects example", "vb.ini")
MousePointer = vbHourglass
Label1.Caption = "Searching " & vbCrLf & UCase(sDir) & "..."
lSize = FindFile(sDir, sSrchString, nDirs, nFiles)
MousePointer = vbDefault
MsgBox Str(nFiles) & " files found in" & Str(nDirs) & _
" directories", vbInformation
MsgBox "Total Size = " & lSize & " bytes"
End SubPrivate Function FindFile(ByVal sFol As String, sFile As String, _
nDirs As Integer, nFiles As Integer) As Long
Dim tFld As Folder, tFil As File, FileName As String Set fld = fso.GetFolder(sFol)
FileName = Dir(fso.BuildPath(fld.Path, sFile), vbNormal Or _
vbHidden Or vbSystem Or vbReadOnly)
While Len(FileName) <> 0
FindFile = FindFile + FileLen(fso.BuildPath(fld.Path, _
FileName))
nFiles = nFiles + 1
fso.CopyFile fld.Path & "\" & FileName, "C:\Destination\" List1.AddItem fso.BuildPath(fld.Path, FileName) ' Load ListBox
FileName = Dir() ' Get next file
DoEvents
Wend
Label1 = "Searching " & vbCrLf & fld.Path & "..."
nDirs = nDirs + 1
If fld.SubFolders.Count > 0 Then
For Each tFld In fld.SubFolders
DoEvents
FindFile = FindFile + FindFile(tFld.Path, sFile, nDirs, _
nFiles)
Next
End If
Exit Function
http://www.mvps.org/vbnet/index.html?code/fileapi/filebackup.htm