获取winform的工程路径

史值拥

关注

阅读 128

2023-02-28


string startupPath = System.Windows.Forms.Application.StartupPath;

string solutionPath = startupPath +@" \..\..\..\";

如果在工程目录下建立了一个Images目录,需要取其中的a.jpg,那么只需要:

Bitmap image = new Bitmap(solutionPath + @"images\a.jpg");


如果是在工程内部,还有更直接的方式,比如:这么写也是可以的:

Bitmap image = new Bitmap(@"..\..\..\images\a.jpg");


OK.

 

​​http://snippetsfor.net/Csharp​​

 

​​http://snippetsfor.net/Csharp/XamlToGraphicsPath​​

精彩评论(0)

0 0 举报