我正在尝试编写一个方法。
public List<string> getList()
{
string[] str;
string no, name, size, price;
string albumFolder = @"F:\Audio";
char a = ' ';
List<string> albums = new List<string>();
albumFolder.Split(Path.DirectorySeparatorChar);
str = albumFolder.Split(Path.DirectorySeparatorChar);
for (int i = 0; i < str.Length; i++)
{
string n = str[i].ToString();
n = n.Split(Path.DirectorySeparatorChar).ToString();
no = (i > 8 ? " " : " ") + (i + 1) + "".PadRight(10, a);
name = n.PadRight((155 - n.Length), a);
size = "" + 512 + " MB".PadRight(20, a); // also help me finding their size
price = "" + 80 + "".PadRight(10, a);
albums.Add(no + name + size + price);
}
return albums;
}
此方法将返回 aList
以便我可以执行此操作:
albumList.DataSource = getList(); //albumList is a ComboBox
这List
应该包含具有所有子文件夹名称(不是位置,仅名称)的固定长度的字符串。但它就像图片一样:
提前致谢...