public class FileNameString: string
{
int maxDisplayLength = 60;
public string DisplayValue
{
get
{
string temp = this;
if (this.length() > maxDisplayLength)
{
if (System.IO.Path.IsPathRooted(temp))
temp = temp.SubString(0,1) +
String.format( "{0}{1}...{1}{2}",
System.IO.Path.VolumeSeparatorChar,
System.IO.Path.PathSeparator, temp)+
System.IO.Path.GetFileName(temp);
else
{
int i = temp.IndexOf(String.Format("{0}{0}", System.IO.Path.VolumeSeparatorChar));
if (i==0)
temp = temp.Substring(0,temp.IndexOf(2,Format("{0}", System.IO.Path.VolumeSeparatorChar),2)) +
String.format( "{0}...{0}",
System.IO.Path.PathSeparator) +
System.IO.Path.GetFileName(temp);
}
}
return temp;
}
}
public string ValueMember
{
get
{
return this;
}
}
public int MaxDisplayLength
{
get
{
return maxDisplayLength;
}
set
{
maxDisplayLength = value;
}
}
public FileNameString(string s, int n):base()
{
this = s;
maxDisplayLength = n;
}
public FileNameString(string s):base()
{
this = s;
}
}