Simple functions:
Using system; <br/> using system. collections. generic; <br/> using system. componentmodel; <br/> using system. data; <br/> using system. drawing; <br/> using system. text; <br/> using system. windows. forms; <br/> using system. io; </P> <p> namespace to open the file <br/>{< br/> Public partial class form1: form <br/> {<br/> string [] linkpath = new string [4]; <br/> Public form1 () <br/>{< br/> initializecomponent (); <br/>}</ P> <p> private void button#click (Object sender, eventargs e) <br/>{< br/> // </P> <p> If (directory. exists (combobox1.text) <br/>{< br/> getall (ref listview1, combobox1.text ); <br/>}< br/> else <br/> {<br/> MessageBox. show ("the specified directory does not exist! "); <Br/>}< br/> protected void initlinkpath () <br/>{< br/> If (directory. exists (combobox1.text) <br/>{< br/> linkpath [0] = combobox1.text; // current path <br/> linkpath [1] = combobox1.text; // backward <br/> linkpath [2] = combobox1.text; // forward <br/> If (combobox1.items. contains (combobox1.text) | combobox1.items. contains (combobox1.text + "//") <br/>{< br/> linkpath [3] = combobox1.text; // up <br/>}< br/> Else <br/> {<br/> linkpath [3] = combobox1.text. substring (0, combobox1.text. lastindexof ("//")); <br/>}</P> <p> // <summary> <br/> // traverse the current directory <br />/// </Summary> <br/> /// <Param name = "listview"> </param> <br/> /// <Param name =" path "> </param> <br/> protected void getall (ref listview, string path) <br/>{< br/> listview. clear (); <br/> initlinkpath (); <br/> If (! Directory. exists (combobox1.text) <br/>{< br/> MessageBox. Show ("the specified directory does not exist! "); <Br/> return; <br/>}</P> <p> // obtain the subdirectory <br/> string [] dirs = directory. getdirectories (PATH); <br/> foreach (string dir in dirs) <br/>{< br/> string STR = dir. replace (path, ""); <br/> If (Str. startswith ("//") <br/>{< br/> STR = Str. remove (0, 1); <br/>}< br/> // listview. items. add (dir. replace (path, ""), 0); <br/> listview. items. add (STR, 0); <br/>}</P> <p> // obtain the file <br/> string [] files = directory. Getfiles (PATH); <br/> foreach (string file in files) <br/>{< br/> string STR = file. replace (path, ""); <br/> If (Str. startswith ("//") <br/>{< br/> STR = Str. remove (0, 1); <br/>}< br/> // listview. items. add (dir. replace (path, ""), 0); <br/> If (Str. tolower (). endswith (". TXT ") <br/>{< br/> // if it is a text file <br/> listview. items. add (STR, 2); // 2 is an image of a text file, self-made image <br/>}< br/> else <br/> {<br/> listview. it EMS. add (STR, 1); <br/>}</P> <p> private void listview#doubleclick (Object sender, eventargs E) <br/> {<br/> // MessageBox. show (listview1.selecteditems. count. tostring (); <br/> If (listview1.selecteditems. count = 0) <br/>{< br/> return; <br/>}< br/> else <br/>{< br/> If (combobox1.text. endswith ("//") <br/>{< br/> combobox1.text = combobox1.text. remove (combobox1.text. length-1, 1); <br/>}< br/> // if you double-click a folder, enter the folder <br/> If (listview1.selecteditems [0]. imageindex = 0) <br/>{</P> <p> combobox1.text = combobox1.text + "//" + listview1.selecteditems [0]. text; <br/> getall (ref listview1, combobox1.text); <br/>}< br/> else <br/>{< br/> // if it is not a directory, open it <br/> string filename = combobox1.text + "//" + listview1.selecteditems [0]. text; <br/> If (filename! = "" & System. io. file. exists (filename) <br/>{< br/> system. diagnostics. process. start (filename); <br/>}</P> <p> private void form1_load (Object sender, eventargs e) <br/>{< br/> string [] drives = environment. getlogicaldrives (); // obtain all logical drive letters </P> <p> combobox1.items. clear (); <br/> foreach (string dirve in drives) <br/>{< br/> combobox1.items. add (dirve); <br/>}</P> <p> Private void button2_click (Object sender, eventargs e) <br/>{</P> <p> combobox1.text = linkpath [3]; <br/> getall (ref listview1, combobox1.text); </P> <p >}</P> <p> private void combobox#selectedindexchanged (Object sender, eventargs E) <br/>{< br/> If (directory. exists (combobox1.text) <br/>{< br/> getall (ref listview1, combobox1.text ); <br/>}< br/> else <br/> {<br/> MessageBox. show ("the specified directory does not exist! "); <Br/>}< br/>}