List with items returns empty

Posted by Power-Mosfet on Stack Overflow See other posts from Stack Overflow or by Power-Mosfet
Published on 2011-01-14T13:30:31Z Indexed on 2011/01/14 13:53 UTC
Read the original article Hit count: 128

Filed under:
|
|
|

I have created a simple List function but if I Loop through the List it's empty. It should not be!

All, thank you for the input. problem solved

// List function 
public class process_hook
{
    public static List<string> pro_hook = list_all_processes();
    protected static List<string> list_all_processes()
    {
        var list = new List<string>();

        foreach (Process i in Process.GetProcesses("."))
        {
            try
            {
                foreach (ProcessModule pm in i.Modules)
                {
                    list.Add(pm.FileName);
                }
            }
            catch { }
        }

        return list;
    }
}



        // call 
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (String _list in process_hook.pro_hook)
            {
                Console.WriteLine(_list);
            }
        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET