[
  {
    "Id": "650043",
    "ThreadId": "267174",
    "Html": "\r\n<p>Hello,</p>\r\n<p>not a question about the library, but I hope to get ideas to find solution :-)</p>\r\n<p>In an archive-file exist the below folder structure:</p>\r\n<pre>\\MainFolder\r\n\\MainFolder\\SubFolder\r\n\\MainFolder\\GUID\r\n\\MainFolder\\GUID\\2ndSubFolder\r\n\\MainFolder\\GUID\\2ndSubFolder\\GUID\r\n...<br>GUID like XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</pre>\r\n<p>My problem is to find the highest folder, here &quot;&#65279;\\MainFolder\\GUID&quot;.</p>\r\n<p>I tried to read all entries with SelectEntries and check the entry with IsDirectory, but I'm unable to find a solution for this issue.</p>\r\n<p>So I would like to ask you about a possibility.</p>\r\n<p>Kind regards,<br>\r\nMaximilian</p>\r\n",
    "PostedDate": "2011-07-30T13:28:06.197-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "650076",
    "ThreadId": "267174",
    "Html": "<p>I don't understand what makes \"\\MainFolder\\GUID\" the \"highest\" folder?&nbsp;&nbsp; Do you mean to sort the folders by folder&nbsp;name?</p>\r\n<p>If so, you can do it with a LINQ query and an orderby clause.</p>\r\n<p>When searching the filesystem you could do something like this:</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">var</span> nameOfLastGuidDirectory = \r\n    (<span style=\"color: blue;\">from</span> dn <span style=\"color: blue;\">in</span> Directory.GetDirectories(<span style=\"color: #a31515;\">\"MainFolder\"</span>, <span style=\"color: #a31515;\">\"????????-????-????-????-????????????\"</span>)\r\n        <span style=\"color: blue;\">orderby</span> dn).Take(1);\r\n\r\n</pre>\r\n</div>\r\n<p>Searching the items in an archive is a little different. There is no concept of a \"directory\" as a container in a zip archive. So you need to parse the FileName of the ZipEntry in order to determine if the \"parent directory\" is a guid, and then order by the parent directory.&nbsp; I think something like this might work:</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre>Regex regexGuid = <span style=\"color: blue;\">new</span> Regex(<span style=\"color: #a31515;\">\"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$\"</span>, RegexOptions.Compiled);\r\n<span style=\"color: blue;\">using</span> (<span style=\"color: blue;\">var</span> zip = ZipFile.Read(archiveToRead))\r\n{\r\n    <span style=\"color: blue;\">var</span> entry = (<span style=\"color: blue;\">from</span> e <span style=\"color: blue;\">in</span> zip.Entries\r\n        <span style=\"color: blue;\">where</span> regexGuid.IsMatch(Path.GetDirectoryName(e.FileName))\r\n        <span style=\"color: blue;\">orderby</span> Path.GetDirectoryName(e.FileName) \r\n        <span style=\"color: blue;\">select</span> e).Take(1);\r\n    <span style=\"color: blue;\">var</span> lastGuid = Path.GetFileName(Path.GetDirectoryName(entry));\r\n}\r\n\r\n</pre>\r\n</div>\r\n<p>I didn't try this...&nbsp;</p>",
    "PostedDate": "2011-07-30T16:42:42.367-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "650127",
    "ThreadId": "267174",
    "Html": "<p>Hi Cheeso,</p>\n<p>you are ﻿brilliant, with your answer I have written my function:</p>\n<div style=\"color: black; background-color: white;\">\n<pre><span style=\"color: blue;\">Private</span> <span style=\"color: blue;\">Function</span> EngFirstGuidPath() <span style=\"color: blue;\">As</span> <span style=\"color: blue;\">String</span>\r\n        <span style=\"color: green;\">'Expression to find a GUID</span>\r\n        <span style=\"color: blue;\">Dim</span> regexGuid <span style=\"color: blue;\">As</span> <span style=\"color: blue;\">New</span> System.Text.RegularExpressions.Regex(<span style=\"color: #a31515;\">\"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\"</span>, System.Text.RegularExpressions.RegexOptions.Compiled)\r\n        <span style=\"color: green;\">'Select all entries like a folder and matched to a GUID</span>\r\n        <span style=\"color: blue;\">Dim</span> GUID_Entries =\r\n            (\r\n                <span style=\"color: blue;\">From</span> DirectoryEntry <span style=\"color: blue;\">As</span> Ionic.Zip.ZipEntry <span style=\"color: blue;\">In</span> _zipFile.Entries\r\n                <span style=\"color: blue;\">Where</span> DirectoryEntry.IsDirectory <span style=\"color: blue;\">And</span> regexGuid.IsMatch(System.IO.Path.GetDirectoryName(DirectoryEntry.FileName))\r\n                <span style=\"color: blue;\">Order</span> <span style=\"color: blue;\">By</span> System.IO.Path.GetDirectoryName(DirectoryEntry.FileName)\r\n            )\r\n        <span style=\"color: green;\">'Return the first folder or nothing if the array count = 0</span>\r\n        <span style=\"color: blue;\">If</span> GUID_Entries.<span style=\"color: blue;\">Count</span> &gt; 0 <span style=\"color: blue;\">Then</span>\r\n            <span style=\"color: blue;\">Return</span> System.IO.Path.GetDirectoryName(GUID_Entries.First.FileName)\r\n        <span style=\"color: blue;\">Else</span>\r\n            <span style=\"color: blue;\">Return</span> <span style=\"color: blue;\">Nothing</span>\r\n        <span style=\"color: blue;\">End</span> <span style=\"color: blue;\">If</span>\r\n<span style=\"color: blue;\">End</span> <span style=\"color: blue;\">Function</span>\r\n</pre>\n</div>\n<p>At finally, the library is very helpful and easy to use it (if you&nbsp;are able to find a solution) &nbsp;:-)</p>\n<p>Thank you for the great library.</p>\n<p>Best regards,<br />Maximilian</p>",
    "PostedDate": "2011-07-31T00:09:40.823-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]