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?
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!
精彩评论