Phonon
Phonon

Reputation: 12737

Formatting a file path that does not fit into a TextBox

I feel this may be a duplicate but I failed to find a similar question, so please redirect me if one exists.

I have a Form in which I display user-selected file path in a TextBox. I've seen many times in other applications that a neat way to deal with a path that's too long to fit into a TextBox (or some other field for that matter) is shortened by putting ellipsis ('...' symbol) in the middle of it.

For example,

C:\Program Files\Some Company\Some Program\bin\application.exe

can be shortened as follows:

C:\Program Files\ ... \ bin\application.exe

Is there any built-in functionality in .NET to do that? Does it have a name so I could search for some tips on how to implement it? Is it generally a good way of fitting a long path into a shorter text field?

Upvotes: 0

Views: 518

Answers (1)

Russ Clarke
Russ Clarke

Reputation: 17909

This is something that I believe can be done with Interop services, but not sure if a native .net method exists.

Try this URL:

http://www.csharpdeveloping.net/CodeSnippets.mvc/Detail/how_to_truncate_file_path

Good luck!

Upvotes: 1

Related Questions