If the line that is giving you the error is
TreeView1.Nodes[0].Text;
then this is telling you that you have no items in
TreeView1.Nodes
. If you put a breakpoint on this line, and debug your application, when you reach this line, right click on the Nodes element and select
QuickWatch from the context menu. You can then inspect what's in
TreeView1.Nodes
.