Ejemplo n.º 1
0
        /// <summary>
        /// Load the profile from a file path
        /// </summary>
        static public SecurityUserProfile LoadFromFile(string path)
        {
            SecurityUserProfile result = null;

            try
            {
                path = FileHelper.ConvertOSFilePath(path);
                if (!File.Exists(path))
                {
                    throw new Exception("File not found: " + path);
                }

                XmlSerializer serializer = new XmlSerializer(typeof(SecurityUserProfile));
                using (XmlReader xr = XmlReader.Create(path))
                {
                    result = (SecurityUserProfile)serializer.Deserialize(xr);
                }
                result.Path = path;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to read the file '{0}'.\r\n{1}\r\n", path, ex.Message, ex.StackTrace));
            }
            return(result);
        }