-
File access
Hi,
can somebody give an equivalent API/ vb Function for the 'C' Access function , where in we can check access (read / write) to a file.
Thanks,
Sharath
//code from msdn
#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" );
}
}
-
Re: File access
check out FileAttr function, or this is the simplest solution when you want to access to C functions, create a DLL that wrap the function.
HTH
cksiow
http://vblib.virtualave.net - share our codes
-
Re: File access
This will do just about what your C code does...
private Sub Command1_Click()
Dim MyFile as string
Dim isReadOnly as Integer
Dim msg as string
MyFile = Dir$("c:\access.c", vbNormal) ' file existance
If MyFile <> "" then
msg = "The file ACCESS.C exists."
isReadOnly = GetAttr("c:\access.c") And vbReadOnly ' file properties
If isReadOnly > 0 then '
msg = msg & vbCrLf & "The file ACCESS.C is read only."
else
msg = msg & vbCrLf & "The file ACCESS.C has full access."
End If
MsgBox msg
else
MsgBox "The file ACCESS.C does not exist."
End If
End Sub