Friday, May 09, 2008

Retrieve File Security Information using C#

Retrieve File Security Information using C#

Verify if file exists in the directory using the System.IO namespace. And retrieving the security information and other details. This as been demonstrated using the Windows forms application.




if (File.Exists(openFileDialog1.FileName))
{
//MessageBox.Show("File exists!");
lbl_existstatus.ForeColor = System.Drawing.Color.SeaGreen;
lbl_existstatus.Text = "File Exist the directory";
}
else
{
lbl_existstatus.ForeColor = System.Drawing.Color.Red;
lbl_existstatus.Text = "File Missing in the directory";
}

Query the secuirty inforamtion of the file using the System.Management.

using (ManagementObject o = new ManagementObject(@"Win32_LogicalFileSecuritySetting.Path='" + fileName + "'"))

No comments:

ASP.NET MVC - Sport Facility Booking system

  The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...