我想使用反射来拉项目名称,但子方法的过程中它给我索引超出边界错误。
I am trying to pull the project name using the reflection, but during the substring method it give me "index out of bound error".
string s = System.Reflection.Assembly.GetExecutingAssembly().Location;
int idx = s.LastIndexOf(@"\");
s = s.Substring(idx, s.Length);
我不明白为什么它是在第三行给出错误。
I don't understand why it is giving error on the third line.
plz帮助。
尝试:
System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)