请高手指点,我上网找了都是可执行文件的路径
请问要如何取子串,或者还有别的办法

解决方案 »

  1.   

    Directory.GetCurrentDirectory()//得到当前工程目录
    Directory.GetCurrentDirectory()+@"\你的文件名"//得到当前工程目录下的文件
      

  2.   


    这个可不是得到的当前工程目录,而是应用程序工作的目录。
    你试试把工程建立一C盘,EXE发布到D盘,看看得到的是什么
      

  3.   

    public void AddFormFile()
            {
                FileAdder pa = new FileAdder();
                if (pa.AddFormFile() == true)
                    textBox2.Text = pa.Getfilename();
            }
            internal class FileAdder
            {
                string filename;
                public bool AddFormFile()
                {
                    System.Windows.Forms.OpenFileDialog ofd = new OpenFileDialog();
                    ofd.Multiselect = true;
                    ofd.Filter = "|*.xls";
                    ofd.FilterIndex = 0;
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        filename = ofd.FileName;
                        DialogResult   result=MessageBox.Show("是否打开Excel文件?","",MessageBoxButtons.YesNo,MessageBoxIcon.Question);   
                        if(result==DialogResult.Yes)                                              
                            System.Diagnostics.Process.Start(filename);                    return true;
                    }
                    else
                        return false;            
                }
       文件路径和文件名会显示在textbox2中。
      

  4.   

      我要的是Visual C# Project file所在的目录
    不是stu\bin\Debug
    而是stu目录下的stu(Visual C# Project file)所在目录
    我的要求是想在stu目录下建个目录图片来专门放图片
    想读取相对路径啊