相对路径
System.Environment.CurrentDirectory;
Application.StartupPath; // 不包括程序名
Application.ExecutablePath; // 包括程序名
ExecutablePath的值为:
C:\Documents and Settings\tfq\My Documents\Visual Studio 2005\Projects\TeleServer\TeleServer\bin\Debug\TeleServer.exe,
而CurrentDirectory和StartupPath的值为:
C:\Documents and Settings\tfq\My Documents\Visual Studio 2005\Projects\TeleServer\TeleServer\bin\Debug
绝对路径
用 System.IO.FileInfo
using System;
using System.IO;
FileInfo fi = new FileInfo(path); //这里的path是相对路径
if (fi.Exists)
Console.WriteLine(fi.FullName); //这个fullName就是绝对路径
用 ASP.NET
String sFullPath = Server.MapPath(path);