private void ArtBtnDe_Click(object sender, RoutedEventArgs e) { string txt = EnTxtEn.Text; byte[] bytes = Encoding.ASCII.GetBytes(txt); ArithmeticCl ar = new ArithmeticCl(bytes); double res = Convert.ToDouble(DeTxtEn.Text); string w = ar.Decode(res, false); DeTxtRes.Text = w; }
private void FileBtnDe_Click(object sender, RoutedEventArgs e) { TextReader tr = new StreamReader(@"..\ArtEncode.txt"); string resultst = tr.ReadToEnd(); double[] result = new double[resultst.Length / 7]; int n = 0; for (int i = 0; i < resultst.Length; i += 7) { string s = "0," + resultst.Substring(i, 7); result[n] = Convert.ToDouble(s); n++; } tr.Close(); // byte[] bytes = File.ReadAllBytes(@"..\test1.txt"); TextWriter tw = new StreamWriter(@"..\ArtDecode.txt"); for (int i = 0; i <= result.Length - 2; i++) { string txt = globalArithmetic.Decode(result[i], false); tw.Write(txt); } string txt1 = globalArithmetic.Decode(result[result.Length - 1], true); tw.Write(txt1); tw.Close(); }