I would like to know how can I set attributes for a file in vb.net
when I open command prompt and I type this I can set attrib
attrib +a +h +s test.txt
how exactly do I do this on vb.net
Try this:
File.SetAttributes(path, File.GetAttributes("test.txt") Or FileAttributes.Archive)
File.SetAttributes(path, File.GetAttributes("test.txt") Or FileAttributes.Hidden)
File.SetAttributes(path, File.GetAttributes("test.txt") Or FileAttributes.System)
Private Sub GAttrib (fpath As String)
'To get attributes: 'fpath must contain the full path and file name ex: C:\\Test.txt MsgBox(File.GetAttributes(fpath).ToString)
To set/change attributes: File.SetAttributes(fpath, FileAttributes.Archive Or FileAttributes.Hidden Or FileAttributes.System Or FileAttributes.ReadOnly)
'You can use a single attribute or a combination like above. 'If you want to check the new attribute(s) repeat the msgbox MsgBox(File.GetAttributes(fpath).ToString)
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.