-2

I have this code

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

This yields a string such as

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

What I want is

"C://Foo//bin"

How do I get that without removing "file://" from the beginning manually?

4

1 回答 1

0

Use Substring

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

or use this

this.Text = Application.StartupPath;
于 2013-03-30T12:44:00.003 回答