c# 调用声音文件
声音
一、使用C#自带的SoundPlayer
using System.Media;
SoundPlayer sound = new SoundPlayer("声音.wav");
sound.Play();
C#中 如何将音乐文件按相对路径存放
在资源文件中,选择 【音频】添加资源,把 声音.wav添加进去。
System.Media.SoundPlayer
sound= new System.Media.SoundPlayer(Properties.Resources.声音);
sound.Play();
C#中资源文件的使用
图片
folderBrowserDialog控件 打开的文件夹浏览对话框
if (this.folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK),文件夹浏览对话框 ,如果点击确定
string dir = this.folderBrowserDialog1.SelectedPath;//// 取得用户选择的路径
// 获取目录下的所有Jpg文件
string[] files = Directory.GetFiles(dir, "*.jpg", SearchOption.AllDirectories);
foreach (string imgFile in files)
{
string imageFileName; //文件名
int width, height; //宽度和高度
float dpiX, dpiY; //水平和垂直分辨率
imageFileName = Path.GetFileName(imgFile);
// 加载图像
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(imgFile))
{
width = bmp.Width;
height = bmp.Height;
dpiX = bmp.HorizontalResolution;
dpiY = bmp.VerticalResolution;
}
string defaultPath = "";
FolderBrowserDialog dialog = new FolderBrowserDialog();
//打开的文件夹浏览对话框上的描述
dialog.Description = "请选择一个文件夹";
//是否显示对话框左下角 新建文件夹 按钮,默认为 true
dialog.ShowNewFolderButton = false;
//首次defaultPath为空,按FolderBrowserDialog默认设置(即桌面)选择
if (defaultPath != "")
{
//设置此次默认目录为上一次选中目录
dialog.SelectedPath = defaultPath;
}
//按下确定选择的按钮
if (dialog.ShowDialog() == DialogResult.OK)
{
//记录选中的目录
defaultPath = dialog.SelectedPath;
}
MessageBox.show(defaultPath);
本文固定链接:http://www.itechzero.com/c-sharp-folderbrowserdialog-usage.html,转载请注明出处。
————————————————
版权声明:本文为CSDN博主「Techzero」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/techzero/article/details/27519785
// 如果目录不存在,先创建目录
if (!Directory.Exists(txtDir.Text))
{
Directory.CreateDirectory(txtDir.Text);
}
// 文件名
string _filename = "file_" + (n + ).ToString();
// 目录的绝对路径
string _dirpath = System.IO.Path.GetFullPath(txtDir.Text);
// 组建新文件的全路径
string fullPath = System.IO.Path.Combine(_dirpath, _filename);
c# 调用声音文件的更多相关文章
- [irving] C# Windows Beep 调用声音文件
方法一:Console.Beep(); 方法二:可以用Console.WriteLine("/a");来代替Beep(). MSDN:http://msdn.microsoft.c ...
- 将声音文件加入VC
概述 VC++是微软公司开发的一个IDE(集成开发环境),换句话说,就是使用c++的一个开发平台.有些软件就是这个编出来的...另外还有VB,VF.只是使用不同语言...但是,VC++是Windows ...
- 给自己的Unity添加声音文件
下面说明一下,在Unity 里是怎么样加载声音文件的. Unity同时支持单声道和立体声音频资产. Unity支持导入以下音频文件格式:.aif, .wav, .mp3, 和 .ogg,和以下音轨模块 ...
- 基于VC的声音文件操作(二)
(二)VC的声音操作 操作声音文件,也就是将WAVE文件打开获取其中的声音数据,根据所需要的声音数据处理算法,进行相应的数学运算,然后将结果重新存储与WAVE格式的文件中去:可以使用CFILE类来实现 ...
- 在C#中调用EXE文件
1. 如果exe文件的返回值是int类型,标识操作执行的结果是否成功,例如: class Program { static int Main(string[] args) { return args. ...
- go 获取函数被调用的文件即行数
import "runtime" _, file, line, ok = runtime.Caller(calldepth) 其中calldepth 指的调用的深度,为0时,打印当 ...
- C++ exe调用dll文件
生成dll程序 extern "C"_declspec(dllexport) void maopao(int *p,int count);void maopao(int *p,in ...
- 基于VC的声音文件操作(四)
(五)读取wav的实例 跟据WAVE文件的格式,实现了读取双声道立体声数据的例子如下: BYTE * GetData(Cstring *pString) //获取声音文件数据的函数,pString参数 ...
- 基于VC的声音文件操作(一)
(一)文件格式 1.RIFF文件结构和WAVE文件格式 Windows支持两种RIFF(Resource Interchange File Format,"资源交互文件格式")格式 ...
随机推荐
- MongoDB状态查询:db.serverStatus()
参见:http://www.2cto.com/database/201501/370191.html 基本信息 spock:PRIMARY>db.serverStatus() { "h ...
- e686. 显示打印窗口
The print dialog allows the user to change the default printer settings such as the default printer, ...
- e649. 处理焦点改变事件
component.addFocusListener(new MyFocusListener()); public class MyFocusListener extends FocusAdapter ...
- Global.asax中使用HttpContext为空
application启动的时候并没有对应的HttpContext.Current请求所以会出错 用System.Web.Hosting.HostingEnvironment.MapPath就可以了
- css -- css选择器
选择器 例子 例子描述 CSS .class .intro 选择 class="intro" 的所有元素. 1 #id #firstname 选择 id="firstna ...
- python cython 模块(1)
python 是一门动态类型的语音,其开发速度比C,C++等静态语言块, 但是速度慢很多, 而cython 通过混合C和python 的语法,可以提高python代码的运行速度 1) 安装cython ...
- 微信绑定用户服务端代码-根据code获取openId然后绑定用户
目录结构: isa.qa.core.weixin.message.resp包和isa.qa.core.weixin.util包中为微信绑定的工具类,就不一一贴出代码,详见附件,下载地址: http:/ ...
- TMS320F28335项目开发记录3_28335简介
28335特性介绍 高性能静态CMOS技术 高达150MHZ(6.67ns的周期时间):1.9V / 1.8内核 ,3.3V I/O设计 高性能32位CPU IEEE- ...
- link with editor
在左侧explore上,有个双向的箭头,点一下,就会把路径和当前文件自动对应
- javaScript实现归并排序
归并排序是一个O(nlogn)的算法,其基本思想就是一个分治的策略,先进行划分,然后再进行合并,下面举个例子.有这样一组数据: {5,4,1,22,12,32,45,21} 如果对它进行归并排序的话, ...