Hack Forums
[.NET] [VB.NET]Give file an attribute - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [VB.NET]Give file an attribute (/showthread.php?tid=397069)



[VB.NET]Give file an attribute - codepoet - May 1, 2010

originally posted on dotnet-snippets.com

Description:

With this function you can give a file an attribute like ready-only.

Code
Public Sub SetAttribute(ByVal FileName As String, ByVal NewAttribute As FileAttribute)
    Dim Attr As FileAttributes
    Attr = File.GetAttributes(FileName)
    File.SetAttributes(FileName, Attr Or NewAttribute)
End Sub

If You Like this tutorial, please check out my other tutorials by clicking ==> H3R3


* - Sikandar - May 1, 2010

you can always just use 1 line of code
File.SetAttributes(FileName, Attribute)

thankz for sharing!
:)


* - codepoet - May 2, 2010

true but this is the proper way of doing it.