OpenFileDialog1 - элемент не существует в данном контексте. Исправляю ошибку эту, так другие ошибки вылазят. Буду очень благодарен кто поможет. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp1 { public partial class Form1 : Form { private byte[] encFile; private void Button2_Click(object sender, EventArgs e) { //choose file int size = -1; DialogResult result = OpenFileDialog1.ShowDialog(); if (result == DialogResult.OK) { string file = OpenFileDialog1.FileName; try { byte[] bytes = File.ReadAllBytes(file); size = bytes.Length; encFile = bytes; } catch (InvalidOperationException exc) { MessageBox.Show(exc.ToString()); } } } public Form1() { InitializeComponent(); } } }
DialogResult result = OpenFileDialog1.ShowDialog(); /// /// OpenFileDialog result = new OpenFileDialog1.ShowDialog();