Results 1 to 8 of 8

Thread: File property >>Resolved<<

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    190

    Unhappy 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.

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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.

    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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.
    -= a peet post =-

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    190
    Thanks Peet

    But if the file is read only how can i set the read only off

    any suggestion ?

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Private Sub Command1_Click()
    2.     SetAttr "C:\TEST.TXT", vbNormal
    3. End Sub

    will turn all attrib. off
    -= a peet post =-

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    If you want to set more than one attribute at the time, you just add them

    example

    VB Code:
    1. Private Sub Command1_Click()
    2.     SetAttr "C:\TEST.TXT", vbArchive + vbHidden
    3. 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 ?
    -= a peet post =-

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Location
    Belgium
    Posts
    190
    Thanks Peet

    that was wat I needid

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    no problemo
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width