Shorten Path name

  • Thread starter Thread starter Tony Maresca
  • Start date Start date
T

Tony Maresca

Is there any framework function or code floating
around that someone knows of, that can take a long
path name and remove the middle parts to make it
fit in a given field of characters for display in my UI?

Thanks,

--
Tony M.
 
Not sure exactly what you mean, but if you wanted - say...

C:\SomeFolder\SubFolderOne\SubSubFolderOne\File.txt

to appear as:

C:\SomeFolder\...File.txt

You could use the string objects methods to concatinate the Left N
characters with "..." and the Right N characters.

There could be several ways to do this, but mostly it comes down to
simple string manipulation.
 
Tony Maresca said:
Is there any framework function or code floating
around that someone knows of, that can take a long
path name and remove the middle parts to make it
fit in a given field of characters for display in my UI?

If you're just worried about displaying the shortened string (i.e. you don't
need to actually know which characters have been removed) then you could try
Graphics.DrawString, using a StringFormat object whose Trimming property is
set to StringTrimming.EllipsisPath.

Chris Jobson
 
Back
Top