標籤:winform style blog http color 檔案
引用
using Shell32;
private void Open_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "MP3 Files(.mp3)|*.mp3|WMA Files(*.wma)|*.WMA"; //ofd.Multiselect = true; //允許多選 ofd.RestoreDirectory = true; //記住上一次的檔案路徑 ofd.ShowDialog(); FilePath = ofd.FileName; if (FilePath != "") { string OpenFileType = Path.GetExtension(FilePath); FileInfo FileLenght = new FileInfo(FilePath); if (FileLenght.Length > 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);//重新命名其實就是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); } } }
解析說明:例子周杰倫 - 青花瓷.mp3
-1 項目類型:MP3檔案
大小:3.62
參與創作的藝術家:周杰倫
長度:00:03:57
0:青花瓷.mp3(檔案名稱)
1: 3.62MB(大小)
2: MP3檔案(項目類型)
3:xxxx-xx-xx xx:xx(修改時間)
9: 音頻(檔案類型)
10:Administrators(使用者名稱)
11:音樂(所屬)
13:周杰倫(演唱)
14:一人一首成名曲(專輯)
15: 2002(年份)
19:未分級
20:周杰倫(演唱)
21:青花瓷(歌名)
27: 00:03:57
28:128kbps
29:否
修改後周杰倫 - 青花瓷.mp3
圖例:
開啟後顯示已修正得到歌曲資訊:
private void UpLoad() { //wenserver需自己定義 WebClient webclient = new WebClient(); byte[] responseArray = webclient.UploadFile("http://192.168.1.11/WebForm1.aspx ", "POST", @"" + FilePath + "");//http路徑 string getPath = Encoding.GetEncoding("UTF-8").GetString(responseArray); FuncClass.ShowInformation("歌曲已"+getPath + "上傳到伺服器");//返回資訊 }