//獲取相對路徑
//例如: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都是要實例化的