WinFrom中如何获取文件图片路径
2013-12-20 21:05
477 查看
【方法一】
/// <summary>
/// 文件路径方法
/// </summary>
/// <param name="fileName">文件名称</param>
/// <returns>返回文件的在整个项目中得位置</returns>
private string fPath(string fileName)
{
string SysPath = Application.StartupPath + @"../../../";
Directory.SetCurrentDirectory(SysPath);
string filePath =
Directory.GetCurrentDirectory() + @"/Resources/" +
fileName;
//在Resources文件夹下
return filePath;
}
<如何调用>
Image fn = Image.FromFile(fPath(CursorStyle));
Bitmap bitMap = new Bitmap(fn);
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
【方法二】
//设置应用程序背景
this.BackgroundImage = Image.FromFile(System.IO.Path.GetFullPath("../../Images/pictures/blue.jpg"));
/// <summary>
/// 文件路径方法
/// </summary>
/// <param name="fileName">文件名称</param>
/// <returns>返回文件的在整个项目中得位置</returns>
private string fPath(string fileName)
{
string SysPath = Application.StartupPath + @"../../../";
Directory.SetCurrentDirectory(SysPath);
string filePath =
Directory.GetCurrentDirectory() + @"/Resources/" +
fileName;
//在Resources文件夹下
return filePath;
}
<如何调用>
Image fn = Image.FromFile(fPath(CursorStyle));
Bitmap bitMap = new Bitmap(fn);
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
【方法二】
//设置应用程序背景
this.BackgroundImage = Image.FromFile(System.IO.Path.GetFullPath("../../Images/pictures/blue.jpg"));
相关文章推荐
- List<>引起的nullpointerexception问题
- python basic
- DropdownList没办法选中值,总是回到第一个值
- mac os x 10.9 U盘通过 Boot Camp Assistant 安装windows7
- 整数取反,人人code--英雄会
- IFTTT Evernote 自动生成笔记
- CSL概述(翻译总结自TI官方文档)
- RBAC(Role-Based Access Control)基于角色的访问控制
- 查看内存命令
- 项目开发计划——机房收费系统
- 不常用的文件分割与合并(使用split和cat)
- 读c语言深度剖析 -- typedef小结(3) 定义结构体
- 理工大学ACM平台题答案关于C语言 1006 Sum Problem
- [分享] C++ How to Program, 8/E (C++大学教程 第8版) 英文版PDF下载
- Flickr Tag Recommendation based on Collective Knowledge
- Json
- 视频流读取与视频帧处理
- 希尔排序
- NSDictionary、NSMutableDictionary
- spark安装