1,对于获取工作目录的汇总
// 获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory
// 获取模块的完整路径。
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
// 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。
System.Environment.CurrentDirectory
// 获取应用程序的当前工作目录。
System.IO.Directory.GetCurrentDirectory()
// 获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
// 获取启动了应用程序的可执行文件的路径。
System.Windows.Forms.Application.StartupPath
也可以用:string str1 = @.\...(注意斜杠前的一个小点)
比如: string curPath = @".\Images\hu.ico";
string curPath =Application.StartupPath+@\Images\hu.ico
// 获取启动了应用程序的可执行文件的路径及文件名
System.Windows.Forms.Application.ExecutablePath
//获取启动应用程序的可执行文件的路径,包括执行文件名字
Application.ExecutablePath;
//获取和设置当前目录
Environment.CurrentDirectory;
2,用图片做画笔
首先,下了一张png格式的画笔图片,之后转换为ico格式(http://www.bitbug.net/上可以在线免费转换)。放到项目的Images下;
然后取得该ico图片;
string curPath = @".\Images\hu.ico";
或者string curPath =Application.StartupPath+@\Images\hu.ico
最后,pictureBox1.Cursor = new Cursor(curPath);即可。
不过由于画笔图片的笔尖和鼠标尖不吻合,所以还要调整一下。