string ThePath=System.IO.Path.GetDirectoryName(Application.ExecutablePath);
//得到的结果是E:\C#\Temp\Path\bin\Debug
现在我在路径E:\C#\Temp\Path\Image下放了几张图片,假如是E:\C#\Temp\Path\Image\student_001.jpg,请问各路高手怎么才能提取出”student_001“这个字符串呢?先声明一下考虑到程序的移植性我不想用绝对路径!

解决方案 »

  1.   

    .代表当前目录
    ..代表上一级目录
    Server.MapPath()用于映射成物理路径
    File,FileInfo类和Directory,DirectoryInfo类可以得到磁盘上的文件夹和文件信息
      

  2.   

    string fileName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
      

  3.   

    Substring(fullFileName.LastIndexOf("\\")+1)
      

  4.   

    string fullFileName=System.IO.Directory.GetCurrentDirectory().ToString();
    string fileName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
    MessageBox.Show(fileName);
    显示结果只是"Debug"也不对哦~~~~