Data Danger
Active member
- Joined
- Mar 25, 2004
- Messages
- 29
Can somebody tell me if there is another way to compact long path names without using the shlwapi.dll file PathCompactPath command or should I still use it in .net. Thanks
Data Danger said:Can somebody tell me if there is another way to compact long path names without using the shlwapi.dll file PathCompactPath command or should I still use it in .net. Thanks
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;
}
}
MyList.DisplayMember = "DisplayMember";
MyList.ValueMember = "ValueMember";
for (int i = 0; i < sa.Count; i++)
MyList.Add(new FileNameString(sa[i].ToString(), 25)