在文件夹路径之前删除File:///

时间:2013-03-30 12:35:15

标签: c# string path

我有这段代码

string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

这会产生一个字符串,例如

"file://C://Foo//bin"

我想要的是

"C://Foo//bin"

如何在不手动删除"file://"的情况下获得该功能?

1 个答案:

答案 0 :(得分:0)

使用子串

            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
        this.Text = path.Substring(6, path.Length - 6);

或使用此

this.Text = Application.StartupPath;
相关问题