user496949
user496949

Reputation: 86165

how to get the path before filename

I have a filename like "c:\temp\test\test.jpg", how can I get "c:\temp\test" directory?

Upvotes: 0

Views: 223

Answers (3)

Karan
Karan

Reputation: 3338

string path = System.IO.Path.GetDirectoryName(fullFileName);

Upvotes: 0

C.Evenhuis
C.Evenhuis

Reputation: 26446

By using System.IO.Path.GetDirectoryName()

Upvotes: 10

Dunc
Dunc

Reputation: 8068

I've always done things like this using the System.IO.FileInfo class. The DirectoryName property should help in this instance.

Upvotes: 0

Related Questions