日期:2014-05-17 浏览次数:21053 次
一个WinForm程序,项目文件存放于D:\Projects\Demo,编译后的文件位于D:\Projects\Demo\bin\Debug,最后的结果如下: 1、System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName=D:\Projects\Demo\bin\Debug\Demo.vshost.exe 2、System.Environment.CurrentDirectory=D:\Projects\Demo\bin\Debug 3、System.IO.Directory.GetCurrentDirectory()=D:\Projects\Demo\bin\Debug 4、System.AppDomain.CurrentDomain.BaseDirectory=D:\Projects\Demo\bin\Debug\ 5、System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase=D:\Projects\Demo\bin\Debug\ 6、System.Windows.Forms.Application.StartupPath=D:\Projects\Demo\bin\Debug 7、System.Windows.Forms.Application.ExecutablePath=D:\Projects\Demo\bin\Debug\Demo.EXE System.Environment.GetEnvironmentVariable("windir")=C:\WINDOWS System.Environment.GetEnvironmentVariable("INCLUDE")=C:\Program Files\Microsoft Visual Studio.NET 2005\SDK\v2.0\include\ System.Environment.GetEnvironmentVariable("TMP")=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp System.Environment.GetEnvironmentVariable("TEMP")=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp System.Environment.GetEnvironmentVariable("Path")=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
------解决方案--------------------
string basicPath = System.AppDomain.CurrentDomain.BaseDirectory; string wordPath = System.IO.Path.Combine(basicPath, "word.doc");