|
-
Dec 31st, 2002, 06:16 AM
#1
Thread Starter
Addicted Member
File property >>Resolved<<
Can we read the file property
I mean if they are read only or hide and others
if we can read that can we change the property
if anyone has a idea about this
thanks in advance
Last edited by Heribertt; Dec 31st, 2002 at 07:29 AM.
-
Dec 31st, 2002, 06:43 AM
#2
-= B u g S l a y e r =-
MSDN
GetAttr Function
Returns an Integer representing the attributes of a file, directory, or folder.
Syntax
GetAttr(pathname)
The required pathname argument is a string expression that specifies a file name. The pathname may include the directory or folder, and the drive.
Return Values
The value returned by GetAttr is the sum of the following attribute values:
Constant Value Description
vbNormal 0 Normal.
vbReadOnly 1 Read-only.
vbHidden 2 Hidden.
vbSystem 4 System file.
vbDirectory 16 Directory or folder.
vbArchive 32 File has changed since last backup.
Note These constants are specified by Visual Basic for Applications. The names can be used anywhere in your code in place of the actual values.
Remarks
To determine which attributes are set, use the And operator to perform a bitwise comparison of the value returned by the GetAttr function and the value of the individual file attribute you want. If the result is not zero, that attribute is set for the named file. For example, the return value of the following And expression is zero if the Archive attribute is not set:
Result = GetAttr(FName) And vbArchive
A nonzero value is returned if the Archive attribute is set.
-
Dec 31st, 2002, 06:43 AM
#3
-= B u g S l a y e r =-
MSDN
SetAttr Statement
Sets attribute information for a file.
Syntax
SetAttr pathname, attributes
The SetAttr statement syntax has these named arguments:
Part Description
pathname Required. String expression that specifies a file name — may include directory or folder, and drive.
attributes Required. Constant or numeric expression, whose sum specifies file attributes.
Settings
The attributes argument settings are:
Constant Value Description
vbNormal 0 Normal (default).
vbReadOnly 1 Read-only.
vbHidden 2 Hidden.
vbSystem 4 System file.
vbArchive 32 File has changed since last backup.
Note These constants are specified by Visual Basic for Applications. The names can be used anywhere in your code in place of the actual values.
Remarks
A run-time error occurs if you try to set the attributes of an open file.
-
Dec 31st, 2002, 07:12 AM
#4
Thread Starter
Addicted Member
Thanks Peet
But if the file is read only how can i set the read only off
any suggestion ?
-
Dec 31st, 2002, 07:21 AM
#5
-= B u g S l a y e r =-
VB Code:
Private Sub Command1_Click()
SetAttr "C:\TEST.TXT", vbNormal
End Sub
will turn all attrib. off
-
Dec 31st, 2002, 07:23 AM
#6
-= B u g S l a y e r =-
If you want to set more than one attribute at the time, you just add them 
example
VB Code:
Private Sub Command1_Click()
SetAttr "C:\TEST.TXT", vbArchive + vbHidden
End Sub
if test1.txt was f.ex. just read only, it will after the sample is run have the Archive and Hidden attrib sat.
am I making sense ?
-
Dec 31st, 2002, 07:28 AM
#7
Thread Starter
Addicted Member
Thanks Peet
that was wat I needid
-
Dec 31st, 2002, 07:32 AM
#8
-= B u g S l a y e r =-
no problemo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|