救命啊!这个问题搜了好长时间都没有解决办法! 在文件夹下有一个000.asf文件,把鼠标放上去会出现一个持续时间,这个持续时间就是播放时间,我要用c#程序获得这个播放时间,怎么做啊,,想了半天了,头大如斗啊!问了好几个论坛了,都没有人会,哪位大虾给我解决了,把分如数奉上啊!帮忙啊!小弟感激不尽啊! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好象你说的那个持续时间不知道怎么获取!private void button4_Click(object sender, EventArgs e) { FileInfo file = new FileInfo(@"E:\e\新建文件夹\A1699654.mp3"); string ss=file.Attributes.ToString(); //创建时间 MessageBox.Show(ss); } 给你段代码参考下吧!使用MCI。 [DllImport("Kernel32", CharSet = CharSet.Auto)] static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength); [DllImport("winmm.dll")] public static extern int mciSendString(string m_strCmd, StringBuilder m_strReceive, int m_v1, int m_v2); 下面是检查声音文件长度的代码: StringBuilder shortpath = new StringBuilder(80); GetShortPathName(@"F:\我的文档\My Music\zhs.mp3", shortpath, shortpath.Capacity); string name = shortpath.ToString(); StringBuilder buf = new StringBuilder(80); mciSendString("close all", buf, buf.Capacity, 0); mciSendString("open " + name + " alias media", buf, buf.Capacity, 0); mciSendString("status media length", buf, buf.Capacity, 0); TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim())); textBox1.Text = ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds + "." + ts.Milliseconds; 用WindowsMediaPlayer控件参考:[currentMedia] 当前媒体属性 currentMedia.duration:double; 媒体总长度 currentMedia.durationString:string; 媒体总长度,字符串格式。如“03:24” currentMedia.getItemInfo(const string); 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述,"Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址 currentMedia.setItemInfo(const string); 通过属性名设置媒体信息 currentMedia.name:string; 同 currentMedia.getItemInfo("Title") Guyschaos:textBox1.Text = ts.ToString();就可以了 Guyschaos 的方法我试了,,可是老报错! 我这没错啊!是不是引用没加啊?using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.IO;using System.Runtime.InteropServices;namespace listbox{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("Kernel32", CharSet = CharSet.Auto)] static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength); [DllImport("winmm.dll")] public static extern int mciSendString(string m_strCmd, StringBuilder m_strReceive, int m_v1, int m_v2); private void button5_Click(object sender, EventArgs e) { StringBuilder shortpath = new StringBuilder(80); GetShortPathName(@"E:\e\新建文件夹\A1699654.mp3", shortpath, shortpath.Capacity); string name = shortpath.ToString(); StringBuilder buf = new StringBuilder(80); mciSendString("close all", buf, buf.Capacity, 0); mciSendString("open " + name + " alias media", buf, buf.Capacity, 0); mciSendString("status media length", buf, buf.Capacity, 0); TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim())); this.textBox1.Text = ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds + "." + ts.Milliseconds; } }} 楼主结贴吧,Guyschaos 的方法ok. DataTablehe Datarow的转换问题?? 如何禁止部分代码的调试? c#外行问个问题 今天用AJAX实现了一个WEBIM,请大家指教 URL中传递参数出现乱码?如何处理? 我装了Frame work 2005 beta版,但没有编辑器,请问用哪个命令可以编译整个解决方案啊? 怎样判断文件正在使用中呀 烦请解读一个解析Quoted_printable编码的子串的函数 如何保存将一个Cursor对象保存为一个.cur的文件 就像Image中的保存一样? c#高手请进来 我想从A页面传值到B页面,然后B页面再返回一个值给A页面 提一个关于连接远程端口的问题
private void button4_Click(object sender, EventArgs e)
{
FileInfo file = new FileInfo(@"E:\e\新建文件夹\A1699654.mp3");
string ss=file.Attributes.ToString(); //创建时间
MessageBox.Show(ss);
}
[DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength); [DllImport("winmm.dll")]
public static extern int mciSendString(string m_strCmd, StringBuilder m_strReceive, int m_v1, int m_v2); 下面是检查声音文件长度的代码:
StringBuilder shortpath = new StringBuilder(80);
GetShortPathName(@"F:\我的文档\My Music\zhs.mp3", shortpath, shortpath.Capacity);
string name = shortpath.ToString();
StringBuilder buf = new StringBuilder(80);
mciSendString("close all", buf, buf.Capacity, 0);
mciSendString("open " + name + " alias media", buf, buf.Capacity, 0);
mciSendString("status media length", buf, buf.Capacity, 0);
TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim()));
textBox1.Text = ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds + "." + ts.Milliseconds;
参考:
[currentMedia] 当前媒体属性
currentMedia.duration:double; 媒体总长度
currentMedia.durationString:string; 媒体总长度,字符串格式。如“03:24”
currentMedia.getItemInfo(const string); 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述,"Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址
currentMedia.setItemInfo(const string); 通过属性名设置媒体信息
currentMedia.name:string; 同 currentMedia.getItemInfo("Title")
textBox1.Text = ts.ToString();就可以了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.Runtime.InteropServices;namespace listbox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} [DllImport("Kernel32", CharSet = CharSet.Auto)]
static extern Int32 GetShortPathName(String path, StringBuilder shortPath, Int32 shortPathLength); [DllImport("winmm.dll")]
public static extern int mciSendString(string m_strCmd, StringBuilder m_strReceive, int m_v1, int m_v2); private void button5_Click(object sender, EventArgs e)
{
StringBuilder shortpath = new StringBuilder(80);
GetShortPathName(@"E:\e\新建文件夹\A1699654.mp3", shortpath, shortpath.Capacity);
string name = shortpath.ToString();
StringBuilder buf = new StringBuilder(80);
mciSendString("close all", buf, buf.Capacity, 0);
mciSendString("open " + name + " alias media", buf, buf.Capacity, 0);
mciSendString("status media length", buf, buf.Capacity, 0);
TimeSpan ts = new TimeSpan(0, 0, 0, 0, (int)Convert.ToDouble(buf.ToString().Trim()));
this.textBox1.Text = ts.Hours + ":" + ts.Minutes + ":" + ts.Seconds + "." + ts.Milliseconds;
}
}
}