第一种方法:

                 利用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());


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wenjie0728/archive/2009/04/14/4073690.aspx

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
猜你喜欢
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案