hi ;
Anyone has an idea hopw can I change through code the properties of a certain file given it's path and name.
for example I would have a txt box to imput file name ,
then a button to change the state from readonly to read/write ....
Printable View
hi ;
Anyone has an idea hopw can I change through code the properties of a certain file given it's path and name.
for example I would have a txt box to imput file name ,
then a button to change the state from readonly to read/write ....
You can do it with API.
Public Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Public Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, _
ByVal dwFileAttributes As Long) As Long
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Can also use the FileSystemObject, ie
object.Attributes [= newattributes]
See help files on the subject, or ask for sample
Why not use VB's SetAttr and GetAttr functions?
Code:SetAttr "MyFile.txt", vbReadOnly