检测到无法访问的代码
我在vs2005底下写程序时,因为OpenFileDialog中没有SafeFileName方法,于是自己就写了两个,其中一个老是出现无法访问的代码,小弟甚是不解,不知道这样对程序有什么影响.百度了下,说是代码前面有return么的,可是我将她提到return前面还是不行,烦劳各位瞅瞅.并给讲解一下它可能会造成怎么样的后果.代码如下
public string SafeFileName { get { string str = this.openFileDialog1.FileName; StringBuilder sbuild = new StringBuilder(); char[] ch = str.ToCharArray(); for ( int count = str.Length-1; ; --count ) { if (ch[count] != '\\') sbuild.Append(ch[count]); } string fileName = sbuild.ToString();//这里的string底下有波浪线,警告无法检测到的代码 return fileName; } }