怎么判断工程目录下是否存在某个文件,若存在就删掉,
谢谢指教!!
谢谢指教!!
解决方案 »
- 请教一个vb连接sql的问题
- MsFlexGrid控件和dategrid控件有什摸地方不一样?
- 如何使用相对路径!
- 在运行到下面这一句 Dim objrs As New ADODB.Recordset 时
- 如何拦截信使服务消息
- 那里有连接SQL2000数据库的文章或例子。
- 怎样学好vb
- 在form1中使用command的click调用form2.show.在form2关闭前,form1无法通过鼠标激活.该如何?
- 如何给自定义控件中添加一个自定义的DataSource属性
- VB如何设置PHOTOSHOP历史记录的路径
- 我使用activereport 打印时总会在末端打出它的版本号和其他信息,怎么取消掉阿?
- 请教如何停止ScriptControl
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
ReportFileStatus = msg
End Function
'返回布尔值:True 存在,False 不存在,filername 文件名
Function FileExist(filename As String)
Dim Fso As New FileSystemObject
If Fso.FileExists(filename) = True Then
FileExist = True
Else
FileExist = False
End If
Set Fso = Nothing
End Function
'返回布尔值:True 存在,False 不存在,foldername 文件夹
Function FolderExist(foldername As String)
Dim Fso As New FileSystemObject
If Fso.FolderExists(foldername) = True Then
FolderExist = True
Else
FolderExist = False
End If
Set Fso = Nothing
End Function关于删除可以使用 SHFileOperation 实现.......
能不能简单一点的语句,我的目的是,判断我的工程目录下有没有一个为xuexi.txt的文件,有的话就删掉这个文件,我想问 的是这个判断语句如何写?
Lib "kernel32" Alias "GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As _
Long) As Long
Sub main()
Dim astr As String
Dim l As Long
astr = String(256, 0) l = GetSystemDirectory(astr, Len(astr))
If l Then
dirstring = Left$(astr, l)
End If
If Dir(dirstring & "\cx.txt") <> "" Then Kill (dirstring & "\cx.txt")End Sub给段代码看看,我看了楼上的兄弟给的代码调试通过的,呵呵~~~!!
检查系统目录下如果有cx.txt那么删除它
他的办法确实简洁实用哦,你要用只要修"改路"径就OK了!!
以上代码在VB6.0 windows 2000 sp4上测试通过