批量读取MP3录音文件名及时长并写入txt

using Shell32;
using System.IO;
<span style="line-height: 24px; font-family: monospace; font-size: 14px; text-align: left; white-space: pre-wrap; background-color: rgb(204, 206, 208); margin: 0px; padding: 0px; color: rgb(0, 128, 0); ">//</span><span style="line-height: 24px; font-family: monospace; font-size: 14px; text-align: left; white-space: pre-wrap; background-color: rgb(204, 206, 208); margin: 0px; padding: 0px; color: rgb(0, 128, 0); ">添加引用:COM组件的 Microsoft Shell Controls And Automation</span>

namespace 批量获取mp3文件名及时长
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] fn = Directory.GetFiles(@"G:\录音\2011\201112\20111201");
            string[] names = new string[fn.Length];
            for (int i = 0; i < fn.Length; i++)
            //foreach (string file in fn)
            {

                //string file = @"E:\luyin\浣犳槸鎴戝唴蹇冪殑涓€棣栨瓕.mp3";
                ShellClass sh = new ShellClass();
                Folder dir = sh.NameSpace(Path.GetDirectoryName(fn[i].ToString()));
                FolderItem item = dir.ParseName(Path.GetFileName(fn[i].ToString()));
                string str = fn[i].ToString() + "," + dir.GetDetailsOf(item, 21); //

                //string[] names = new string[fn.Length];

                //for (int i = 0; i < fn.Length; i++)
                //{
                names[i] = str;
                //}

                Console.WriteLine(str);

            }

            StreamWriter sw = File.AppendText(@"G:\testing3.txt");
            foreach (string ly in names)
            {
                sw.WriteLine(ly);
            }
            sw.Flush();
            sw.Close();
            Console.ReadLine();
        }
    }
}
<span style="margin: 0px; padding: 0px; font-family: 'Courier New'; line-height: 1.8; ">// 如果执行过程中,出现是错误提示,通过</span><span style="margin: 0px; padding: 0px; font-family: 'Courier New'; line-height: 1.8; ">Shell32 的 </span><span style="margin: 0px; padding: 0px; font-family: 'Courier New'; line-height: 1.8; ">Embed Interop Types 属性设置为 False 即可;</span>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值