C#播放声音的两个方法 + 流读写文件
2009-04-14 18:12
447 查看
利用API播放声音文件
using System.Runtime.InteropServices; 在调用API时先引用
[DllImport("winmm")]
public static extern bool PlaySound(string szSound, IntPtr hMod, int i); //声明API:PlaySound
调用:
PlaySound(@"声音文件路径",IntPtr.Zero,1);
利用windows media player播放声音
System.Media.SoundPlayer media = new System.Media.SoundPlayer(@"声音文件路径");
mdeia.Play();
流写文件
System.IO.StreamWriter strwri = File.CreateText(@"d:/111.log");
strwri.WriteLine("abc");
strwri.WriteLine("def");
strwri.Flush();
strwri.Dispose();
流读文件
StreamReader dd = new StreamReader(@"d:/11.txt");
MessageBox.Show(dd.ReadLine());
using System.Runtime.InteropServices; 在调用API时先引用
[DllImport("winmm")]
public static extern bool PlaySound(string szSound, IntPtr hMod, int i); //声明API:PlaySound
调用:
PlaySound(@"声音文件路径",IntPtr.Zero,1);
利用windows media player播放声音
System.Media.SoundPlayer media = new System.Media.SoundPlayer(@"声音文件路径");
mdeia.Play();
流写文件
System.IO.StreamWriter strwri = File.CreateText(@"d:/111.log");
strwri.WriteLine("abc");
strwri.WriteLine("def");
strwri.Flush();
strwri.Dispose();
流读文件
StreamReader dd = new StreamReader(@"d:/11.txt");
MessageBox.Show(dd.ReadLine());
相关文章推荐
- C#播放声音的四种方法
- PHP读写文件的两个方法(CodeIgniter框架)
- C#读写txt文件的两种方法介绍
- C#文件读写常用方法
- VC++中播放声音文件的几种不同方法
- [C#] 读写App.config配置文件的方法
- “在win7下用WebEx 播放器播放 *.wrf格式文件耳机没有声音” 解决方法
- 几种C#实现播放声音的方法 DirectX、SoundPlayer等
- [转载]C#读写txt文件的两种方法介绍
- C#读写文件的方法汇总
- C#中最简单的读写文件的方法
- 用C#读写文件的方法
- C#编写Windows桌面应用程序播放MP3声音文件
- 几种C#实现播放声音的方法
- C#读写txt文件的两种方法
- C#播放声音【六种方法】
- 关于用低级API函数播放wav文件声音不连续的解决方法
- C# 读写文件的方法汇总
- C#读写config配置文件的方法
- C#读写txt文件的两种方法介绍