WinFrom中如何获取文件图片路径

来源:互联网 发布:适合iphone的软件 编辑:程序博客网 时间:2024/04/30 17:11

 【方法一】       

        /// <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"));

0 0
原创粉丝点击