zoukankan      html  css  js  c++  java
  • C#中获取音频文件时长

    1.在项目中添加引入:COM组件的Microsoft Shell Controls And Automation

    2.在引用中找到Shell32,点击右键,在属性中将“嵌入互操作类型”的值改为“false”

    3.代码

     1 public static string GetVoiceTime(string voicePath)//voicePath为语音文件路径
     2         {
     3             string path = HttpContext.Current.Server.MapPath(voicePath);//将虚拟路径转换为绝对路径,这里必须用绝对路径
     4             string dirName = Path.GetDirectoryName(path);//获取文件夹名称
     5             string voiceName = Path.GetFileName(path);//获取文件名
     6             FileInfo file = new FileInfo(path);
     7             ShellClass sh = new ShellClass();
     8             Folder dir = sh.NameSpace(dirName);
     9             FolderItem item = dir.ParseName(voiceName);
    10             string songTime = dir.GetDetailsOf(item, 27);//win7参数为27
    11             return songTime;
    12         }

      

  • 相关阅读:
    大道至简第四章读后感
    进度条08
    大道至简第五章读后感
    加密算法
    程序从命令行接收多个数字,求和之后输出结果。
    用JAVA制作简单登录窗口
    进度条07
    冲刺07
    冲刺06
    冲刺05
  • 原文地址:https://www.cnblogs.com/sunshineground/p/3637940.html
Copyright © 2011-2022 走看看