I think that I have captured the file name from a file on my hard drive and I think I have loaded the contents of the file into an array. The code I used is:

public void openFileDialog1FileOk(object sender, System.ComponentModel.CancelEventArgs e)
            string fullPathname1 = openFileDialog1.FileName;
            FileInfo src = new FileInfo(fullPathname1);

            TextReader reader = src.OpenText();
            string line = reader.ReadLine();
            while (line != null)

        public void ReadWholeArray1(Stream fullPathname1, int[] dataTable)
            StreamReader reader = new StreamReader(fullPathname1);
            int i = 0;
            int fileLength = dataTable.Length;
            dataTable = new int[fileLength];
            while (i != fileLength)
                dataTable[i] = reader.Read();

The problem is that when I go to another part of the program to obtain the contents of the array, with something like:

   abyte = dataTable[i];

I get the message: The name 'dataTable' does not exist in the current context.

If I have declared the methods as "public", shouldn't I be able to retrieve the data
from the array anywhere in the program?

dataTable only exist within the context of the method as that is where it was declared. You need to learn about scope, scope tutorial

And for future reference, enclose your code in [code] [/code] tags. It keeps the formatting and makes it easier to talk about when I can say things like "what is the purpose of lines 6-12?"

Also make better titles. We know you need help, that's why you came here. Something like 'Variable doesn't exist in current context - dataTable' is better. Others who might have the same problem would know to look here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.