First, you must add shell32: The program needs to reference shell32.dll. My specific steps are as follows: Right-click "Reference" and choose "add reference". In the displayed dialog box, select the "com" tab, find the Microsoft shell controls andautomation 1.0 component"
Using system. io; using shell32; openfiledialog ofd = new openfiledialog (); // a new method ofd. filter = "MP3 files(folder) | *. MP3 | WMA files (*. WMA) | *. WMA | all files (*. *) | *. * "; ofd. multiselect = true; // multiple ofd options are allowed. restoredirectory = true; // remember the last file path ofd. showdialog (); // display the file opening window filepath = ofd. filename; // obtain the complete file path fileinfo finfo = new fileinfo (filepath); shellclass SH = new shellclass (); folder dir = Sh. namespace (path. getdirectoryname (filepath); folderitem item = dir. parsename (path. getfilename (filepath); stringbuilder sb = new stringbuilder (); For (INT I =-1; I <50; I ++) {sb. append (I. tostring (); sb. append (":"); sb. append (dir. getdetailsof (item, I); sb. append ("\ r \ n");} string STR = sb. tostring ();
Output result:
-1: Project type: MP3 audio size: 5.42 mb artist: Zhang jingxuan length: 00:03:51
0: The Kiss is too realistic. 42 mb2: MP3 format sound/7/30/8/3/7/30/17: 036: A7: 8: 9: audio 10: ZJD-PC \ zjd11: Music 12: 13: Zhang jingxuan 14: urban emotions15: 200816: Chinese pop music [Chinese pop music] 17: 18: 19: not rated 20: Zhang jingxuan 21: The Kiss is too realistic 22: 23: 24: 25: 26: 1427: 00: 03: 5128 :? 196kbps29: No 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: