![]() |
Tipp 0097
|
Datei-Attribute lesen und setzen
|
 |
|
Autor/Einsender: Datum: |
|
Detlev Schubert 14.07.2001 |
|
Entwicklungsumgebung: |
|
VB 5 |
|
|
Dieses Beispiel zeigt auf, wie einfach es ist, mit VB-Mitteln die Attribute von Dateien
zu lesen und auch zu setzen. Dazu bietet VB die komplette Palette aller benötigten
Funktionen. In diesem Tipp wurde das Lesen und Setzen des Datei-Datums nicht berücksichtigt.
Dies lässt sich jedoch mit der VB-Funktion FileDateTime realisieren.
|
|
|
Option Explicit
Dim Attr As Integer, AttributWert(3)
Dim D As String, Pfad As String
Dim m As Integer
Private Sub Form_Load()
AttributWert(0) = vbReadOnly
AttributWert(1) = vbHidden
AttributWert(2) = vbSystem
AttributWert(3) = vbArchive
End Sub
Private Sub Check1_Click(index As Integer)
Attr = 0
For m = 0 To 3
Attr = Attr + AttributWert(m) * Check1(m).Value
Next
End Sub
Private Sub Command1_Click(index As Integer)
Select Case index
Case 1
For m = 0 To File1.ListCount - 1
If File1.Selected(m) Then
SetAttr Pfad$ + File1.List(m), Attr
End If
Next
Case Else
Unload Me
End
End Select
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Pfad$ = File1.Path
If Right$(Pfad$, 1) <> "\" Then Pfad$ = Pfad$ + "\"
End Sub
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
Drive1.Drive = Dir1.Path
End Sub
Private Sub File1_Click()
D$ = Pfad$ + File1.FileName
Label1 = " " + D$
End Sub
Private Sub Label1_Change()
Attr = GetAttr(D$)
For m = 0 To 3
Check1(m).Value = -((Attr And AttributWert(m)) > 0)
Next
End Sub
|
|
|
|
|
Betriebssystem/VB-Version |
Win 9x |
 |
|
Win ME |
 |
|
Win NT |
 |
|
Win 2000 |
 |
|
Win XP |
 |
|
Win
Vista |
 |
|
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (2,6 kB)
|
Downloads bisher: [ 2533 ]
|
|
|