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.
}
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.
}
}
}
User contributions licensed under CC BY-SA 3.0