Esempio n. 1
0
        public static void WriteFile(JObject data, string name, XferFactory.FileType type, string directory)
        {
            string dir = ValidateDirectory(directory, type);

            string encrypt = SecurityFactory.Encrypt(data.ToString(), SecurityFactory.SecurityKey);

            using (StreamWriter file = new StreamWriter(dir + "\\" + name + XferFactory.GetTypeExtension(type)))
            {
                file.Write(encrypt);
            }
        }
Esempio n. 2
0
        public static JObject ReadFile(string path)
        {
            string result = "";

            if (!File.Exists(path))
            {
                return(null);
            }

            using (StreamReader file = new StreamReader(path))
            {
                result = file.ReadToEnd();
            }

            string decrypt = SecurityFactory.Decrypt(result, SecurityFactory.SecurityKey);

            JObject data = JObject.Parse(decrypt);

            return(data);
        }