在中间省略号长路径 [英] Long path with ellipsis in the middle

查看:109
本文介绍了在中间省略号长路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想截断很长的路径,具体长度。不过,我想在中间的省略号

I would like to truncate a long path to specific length. However, I want to have the ellipsis in the middle.

例如: \\my\long\path\is \really\long\and\it\\\
eeds\to\be\truncated

应该成为(最多为35个字符): \\my\long\path\is ... to\be\truncated

有没有一个标准功能或扩展方法可用?

Is there a standard function or extension method available?

推荐答案

有没有标准的函数或扩展方法,所以你必须推出自己的。

There is no standard function or extension method, so you will have to roll your own.

检查长度和使用的东西等;

Check for length and use something like;

var truncated = ts.Substring(0, 16) + "..." + ts.Substring((ts.Length - 16), 16);

这篇关于在中间省略号长路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆