列表框中每个项目的大小

列表框中每个项目的大小

问题描述:

我想在列表框中获取每个项目的大小并显示它.

更新:

我用openfiledialog将文件添加到列表框中.我想获取添加到列表框中的所有文件的大小.

抱歉,第一次没有这么详尽.

I would like to get the size of each item in a list box and display it.

Update:

Im adding files to the listbox with a openfiledialog. I want to get the size of all the files that is added to the listbox.

Sorry for not being this elaborate first time around.

按尺寸,您是指长度吗?如果是这样,则意味着列表框包含字符串的集合.在这种情况下,只需在每个string上使用Length 属性.

[更新]
-----------

回应您的更新问题.在每个路径字符串上使用FileInfo ,然后获取Length 属性.此处的更多信息: http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length.aspx [
By size, do you mean length? And if so that''d mean the listbox contains a collection of strings. In that case, just use the Length property on each string.

[Update]
-----------

In response to your updated question. Use FileInfo on each path-string and then get the Length property. More info here: http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length.aspx[^]