Can anyone help me with this error?? 0x80041002

1

unknown error 0x80041002

c# programming

I have a listview

I am able to via openfiledialog, open file paths and put them into the listview

I will save them in text file format and close my c# winform application

Open it up again and tried to place the saved files back into the listview.

I will "check" the checkered box on the files that i want to run

When i clicked on the "run" button,

Unknown Error: 0x80041002 Pops out

foreach (ListViewItem subItem in list.CheckedItems) 
{ 
    string checkedItems = list.CheckedItems[0].SubItems[1].Text; 
    Process proc = Process.Start(checkedItems); 
    proc.WaitForExit(); // Waits for the process to end. 
}
c#
asked on Stack Overflow Aug 12, 2010 by Jonny • edited Jan 4, 2011 by Dan J

1 Answer

2

That error is thrown when you pass a wrong path to Process.Start

You should add to your code some verification

foreach (ListViewItem subItem in list.CheckedItems) 
{ 
    if(list.CheckedItems.Count > 0)
    {
        string checkedItems = list.CheckedItems[0].SubItems[1].Text; 
        if(File.Exists(checkedItems)
        {
            Process proc = Process.Start(checkedItems); 
            proc.WaitForExit(); // Waits for the process to end. 
        }
    }
}
answered on Stack Overflow Aug 12, 2010 by Wildhorn • edited Aug 13, 2010 by Wildhorn

User contributions licensed under CC BY-SA 3.0