کد قفل کردن فولدر
کد:
using System.IO;
کد:
DirectoryInfo di = new DirectoryInfo("d:\\folder");
2DirectorySecurity ds = di.GetAccessControl();
3FileSystemAccessRule ar = new FileSystemAccessRule(Environment.UserDomainName+"\ \"+Environment.UserName, FileSystemRights.FullControl, AccessControlType.Deny);
4ds.AddAccessRule(ar);
5di.SetAccessControl(ds);
نحوه ذخیره اطلاعات در فایل XML
کد:
XmlTextWriter XmlWrt = new XmlTextWriter("AppXml.xml", System.Text.Encoding.UTF8);
XmlWrt.Formatting = Formatting.Indented;
XmlWrt.WriteStartDocument();
XmlWrt.WriteStartElement("configuration");
XmlWrt.WriteStartElement("general");
XmlWrt.WriteElementString("Name", "Name of User");
XmlWrt.WriteElementString("Familly", "Familly of User");
XmlWrt.WriteEndElement();
XmlWrt.WriteStartElement("Info");
XmlWrt.WriteElementString("User", "UserName");
XmlWrt.WriteElementString("DateExp", "Date of Expire");
XmlWrt.WriteEndElement();
XmlWrt.WriteEndElement();
XmlWrt.WriteEndDocument();
XmlWrt.Close();