//获取相对路径
//例如:System.Windows.Forms.Application.StartupPath = "F:\Sample_01\Material\bin\Debug"
//经过以下处理将返回"F:\Sample_01\Material\images\01.gif"
- string path=System.Windows.Forms.Application.StartupPath + @"../../";
- System.IO.Directory.SetCurrentDirectory(path);
- string strFilePath = System.IO.Directory.GetCurrentDirectory() + @"\images\01.gif";
c#对文件和文件夹的操作主要用到的类是File、FileInfo和Directory、DirectoryInfo
其中FileInfo和DirectoryInfo都是要实例化的