开发者

Can anyone help me with this error?? 0x80041002

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].SubItem开发者_如何转开发s[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. 
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜