Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按全名VB.net对ZipArchive进行排序_Vb.net_Sorting_Zipfile - Fatal编程技术网

按全名VB.net对ZipArchive进行排序

按全名VB.net对ZipArchive进行排序,vb.net,sorting,zipfile,Vb.net,Sorting,Zipfile,我正在处理ZIP文件,并使用以下代码: Dim archive As ZipArchive archive = ZipFile.OpenRead(Filelocation) Do While (stopLoop) entry = archive.Entries.Item(counter) If (entry.FullName.Contains(".jpeg") Or entry.FullName.Contains(".jpg") Or entry.FullName.Cont

我正在处理ZIP文件,并使用以下代码:

Dim archive As ZipArchive

archive = ZipFile.OpenRead(Filelocation)

Do While (stopLoop)
    entry = archive.Entries.Item(counter)

    If (entry.FullName.Contains(".jpeg") Or entry.FullName.Contains(".jpg") Or entry.FullName.Contains(".png")) Then
        stopLoop = False
    Else
        counter += 1
    End If
Loop

这些zip文件包含图像和文档,但图像是按特定顺序排列的。用户可以翻阅图像,有时我的代码工作得很好(图像显示1到10),但其他时候,顺序完全是垃圾(图像显示2,9,3,7,8…)。我知道这些条目是基于它们被添加到归档文件中的时间,但是是否有按全名对它们进行排序的方法?

在没有测试的情况下,我会假设归档文件中的每个条目都有类似于
的内容。entries.OrderBy(Function(e)e.fullname)
可以工作。那与档案无关。这就是你在VB.NET中排列可枚举列表的方式。非常感谢!我试图弄清楚“OrderBy”是如何工作的,但我弄不明白。我已经对代码进行了测试,并做了一些细微的更改(e改为存档),但它工作得很好。当它指的是条目而不是存档时,为什么要将
e
改为
archive
?我倾向于使用类型名的第一个字母,因为它对于这样一个本地化的代码位来说已经足够指示了,并且它允许您在其他地方使用全名,就像我在这段代码中对
entry
所做的那样。@jmcilhinney可能在一个事件处理程序中,自动生成的
e作为EventArgs
,当我想使用自己的变量
e
@AndrewMorton时,我总是发现这是一个轻微的麻烦,很好
e
可能不是一个选项,除非您更改事件处理程序参数名称,但是
archive
将不是一个合适的选择。