webform
var s = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; //C盘 IIS路径 var s1 = System.Environment.CurrentDirectory; //同上 var s2 = System.IO.Directory.GetCurrentDirectory();//同上 var s3 = System.AppDomain.CurrentDomain.BaseDirectory; //当前项目根目录 var s4 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //同上
winform System.Windows.Forms.Application.StartupPath System.Windows.Forms.Application.ExecutablePath
原文:http://www.cnblogs.com/wdw31210/p/4304987.html