先引用:microsoft scripting runtime
如:贺巧D盘的上的aa.txt文件档腊
---
---
Private Sub Command1_Click()
Dim hwndcalc As Integer
Dim fso As New FileSystemObject
If fso.FileExists("d:\aa.txt") = True Then
MsgBox "此文件存在!"
Else
MsgBox "此文件不存在!禅蠢键"
Exit Sub
End If
On Error GoTo err:
fso.CopyFile "d:\aa.txt", "e:\aa.txt", True
MsgBox "打开了!"
Exit Sub
err:
MsgBox "没打开!"
End Sub
用_access函数判断,再次打开时的情况要看你第一次的打开方式侍槐核了,如果上次用的是非独占打开,那没问题,如果是独占打开,会老掘打开失败Example
/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <明孙stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" )
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" )
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)