Net-informations.com
SiteMap  | About    

Set File Attributes

The System.IO namespaces contain types that support input and output, including the ability to read and write data to streams either synchronously or asynchronously.

FileInfo Class Provides instance methods for the creation, copying, deletion, moving, and opening of files. FileSystemInfo.Attributes property is used to gets or sets the attributes for the current file or directory.

  _file.Attributes = IO.FileAttributes.ReadOnly

The following vb.net program shows how to set readonly and hidden property to a file .




Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Try
			Dim _file As IO.FileInfo = My.Computer.FileSystem.GetFileInfo("c:\test.txt")
			_file.Attributes = IO.FileAttributes.ReadOnly
			_file.Attributes = IO.FileAttributes.Hidden
		Catch ex As System.IO.FileNotFoundException
			MsgBox(ex.ToString())
		End Try
	End Sub

End Class






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.