/// <summary> /// 获取解密后的文件内容——字符串 /// </summary> /// <param name="path">文件路径</param> /// <returns>文件内容</returns> public string ReadLicFile(string path, string key, string iv = null) { if (!File.Exists(path)) { throw new Exception("文件不存在!"); } string str = ""; IFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { str = (string)binaryFormatter.Deserialize(fileStream); fileStream.Close(); } if (string.IsNullOrEmpty(iv)) { return(Cryptor.DESDecrypt(str, key)); } return(Cryptor.DESDecrypt(str, key, iv)); }