C # resolve MP3 naming rules and upload them to the server

Source: Internet
Author: User
Reference
Using shell32;

 

Private void open_click (Object sender, routedeventargs e) {openfiledialog ofd = new openfiledialog (); ofd. filter = "MP3 files(folder) | *. MP3 | WMA files (*. WMA) | *. WMA "; // ofd. multiselect = true; // multiple ofd options are allowed. restoredirectory = true; // remember the last file path ofd. showdialog (); filepath = ofd. filename; If (filepath! = "") {String openfiletype = path. getextension (filepath); fileinfo filelenght = new fileinfo (filepath); If (filelenght. length & gt; 10240000) {funcclass. showerror ("too large! ");} Else {shellclass SH = new shellclass (); folder dir = Sh. namespace (path. getdirectoryname (filepath); folderitem item = dir. parsename (path. getfilename (filepath); string newpath = path. getdirectoryname (filepath) + "\" + dir. getdetailsof (item, 20) + "-" + dir. getdetailsof (item, 21) + openfiletype; If (! File. exists (newpath) {file. move (filepath, newpath); // rename is actually move} dir = Sh. namespace (path. getdirectoryname (newpath); item = dir. parsename (path. getfilename (newpath); pathfile. TEXT = newpath; filename. TEXT = path. getfilenamewithoutextension (newpath) + openfiletype; musicname. TEXT = dir. getdetailsof (item, 21); writewords. TEXT = ""; writemusic. TEXT = ""; singer. TEXT = dir. getdetailsof (item, 13); album. TEXT = dir. getdetailsof (item, 14); time. TEXT = dir. getdetailsof (item, 27 );}}}

Explanation: Example: Jay Chou-Qinghua Porcelain

-1 project type: MP3 file
Size: 3.62
Artist: Jay Chou
Length: 00: 03: 57
0: blue/white porcelain enamel (file name)
1: 3.62 MB (size)
2: MP3 files (project type)
3: XXXX-XX: XX (modification time)
9: audio (file type)
10: Administrators (user name)
11: Music)
13: Jay Chou (singing)
14: one name Song (album)
15: 2002 (year)
19: not graded
20: Jay Chou (singing)
21: blue/White Porcelain (song name)
27: 00:03:57
28: 128 Kbps
29: No

After modification, Jay Chou-Qinghua Porcelain

Legend:

After opening, the corrected song information is displayed:

Private void upload () {// wenserver needs to define WebClient = new WebClient (); byte [] responsearray = WebClient. uploadfile ("http: // 192.168.1.11/webform1.aspx", "Post", @ "" + filepath + ""); // HTTP path string getpath = encoding. getencoding ("UTF-8 "). getstring (responsearray); funcclass. showinformation ("song already" + getpath + "upload to server"); // return information}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.