• Friday, February 28, 2014

    How to set attribute of file/folder in visual basic 6

    To set attribute use this:

    1. Private Declare Function SetFileAttributes Lib "kernel32" Alias _
    2. "SetFileAttributesA" (ByVal lpFileName As String,_
    3. ByVal dwFileAttributes As Long) As Long
    5. Private Sub cmd_Click()
    6. SetFileAttributes "c:\a.txt", vbArchive
    7. End Sub

    Where "c:\a.txt" is a filename, you can replace it by directory name or filename.
    Instead of vbAchrive you use:

    • vbHidden
    • vbSystem
    • vbReadOnly
    or you can use combination of it.

    setFileAttributes "c:\a.txt", vbHidden + vbSystem

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment