码迷,mamicode.com
首页 > 其他好文 > 详细

c# 通过解析mp3规范命名并上传服务器

时间:2014-07-16 16:13:10      阅读:210      评论:0      收藏:0      [点我收藏+]

标签: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

图例:

bubuko.com,布布扣

打开后显示已修正得到歌曲信息:

bubuko.com,布布扣

        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 + "上传到服务器");//返回信息
        }

c# 通过解析mp3规范命名并上传服务器,布布扣,bubuko.com

c# 通过解析mp3规范命名并上传服务器

标签:winform   style   blog   http   color   文件   

原文地址:http://www.cnblogs.com/Events/p/3848567.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!