Как сконвертировать byte[] в string - C#
Формулировка задачи:
В реестре ключ в byte[]. Мне нужно его вытащить. И он должен быть в string. Как это сделать??????
Решение задачи: «Как сконвертировать byte[] в string»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Microsoft.Win32;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- RegistryKey r = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Mail.Ru").OpenSubKey("Agent").OpenSubKey("magent_logins3");
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- string[] s = r.GetSubKeyNames();
- for (int y = 0; y <= 1; y++)
- {
- DataGridViewColumn column = new DataGridViewColumn();
- if (y == 0)
- column.HeaderText = "Mail";
- else
- column.HeaderText = "Password";
- dataGridView1.Columns.Add(column);
- }
- for (int i = 0; i < s.Length; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- for (int y = 0; y <= 1; y++)
- {
- row.Cells.Add(new DataGridViewTextBoxCell());
- }
- dataGridView1.Rows.Add(row);
- dataGridView1.Rows[i].Cells[0].Value = s[i];
- RegistryKey c = r;
- r.OpenSubKey(s[i]);
- string[] pas = c.GetValueNames();
- textBox1.Lines = pas;
- MessageBox.Show(" " + s[i]);
- foreach (string t in pas)
- {
- dataGridView1.Rows[i].Cells[1].Value = Encoding.ASCII.GetString((byte[])r.GetValue(t));
- }
- }
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д