[英]using vb.net to set file attributes
我想知道如何在vb.net中設置文件的屬性
當我打開命令提示符並鍵入此命令時,可以設置屬性
attrib +a +h +s test.txt
我怎么在vb.net上做到這一點
嘗試這個:
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)
私有子GAttrib(fpath作為字符串)
'要獲取屬性:'fpath必須包含完整路徑和文件名,例如:C:\\ Test.txt MsgBox(File.GetAttributes(fpath).ToString)
設置/更改屬性:File.SetAttributes(fpath,FileAttributes.Archive或FileAttributes.Hidden或FileAttributes.System或FileAttributes.ReadOnly)
'您可以使用單個屬性或上述組合。 '如果要檢查新屬性,請重復msgbox MsgBox(File.GetAttributes(fpath).ToString)
結束子
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.