示例#1
0
        public static bool Store(Session.Data sessionData)
        {
            Clear();

            EnsureDirectory();

            try
            {
                using (Stream stream = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    formatter.Serialize(stream, sessionData);
                }
            }
            catch (IOException e)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        public static bool Load(out Session.Data sessionData)
        {
            EnsureDirectory();

            try
            {
                using (Stream stream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
                {
                    sessionData = (Session.Data)formatter.Deserialize(stream);

                    stream.Close();

                    return(true);
                }
            }
            catch (IOException e)
            {
                sessionData = null;
                return(false);
            }
        }