Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would use a <code>Dictionary&lt;string,string&gt;</code> with the FullName (path+file+ext) changed to lower case as key and the FullName unchanged as value. Then split the required parts using the static methods <code>GetDirectoryName</code> and <code>GetFileName</code> of the <code>System.IO.Path</code> class before inserting them into the table.</p> <p><strong>EDIT</strong>: The <code>GetFiles</code> method of the <code>DirectoryInfo</code> class returns an array of <code>FileInfo</code>. <code>FileInfo</code> has a <code>FullName</code> property returning path+file+ext. You could as well store this <code>FileInfo</code> as value in your dictionary if memory consumption is not an issue. <code>FileInfo</code> has a <code>DirectoryName</code> and a <code>Name</code> property returning the two parts you need.</p> <p><strong>EDIT</strong>: Here is my implementation of a multimap which does the <code>Directory&lt;TKey,List&lt;TValue&gt;&gt;</code> stuff:</p> <pre><code>/// &lt;summary&gt; /// Represents a collection of keys and values. Multiple values can have the same key. /// &lt;/summary&gt; /// &lt;typeparam name="TKey"&gt;Type of the keys.&lt;/typeparam&gt; /// &lt;typeparam name="TValue"&gt;Type of the values.&lt;/typeparam&gt; public class MultiMap&lt;TKey, TValue&gt; : Dictionary&lt;TKey, List&lt;TValue&gt;&gt; { public MultiMap() : base() { } public MultiMap(int capacity) : base(capacity) { } /// &lt;summary&gt; /// Adds an element with the specified key and value into the MultiMap. /// &lt;/summary&gt; /// &lt;param name="key"&gt;The key of the element to add.&lt;/param&gt; /// &lt;param name="value"&gt;The value of the element to add.&lt;/param&gt; public void Add(TKey key, TValue value) { List&lt;TValue&gt; valueList; if (TryGetValue(key, out valueList)) { valueList.Add(value); } else { valueList = new List&lt;TValue&gt;(); valueList.Add(value); Add(key, valueList); } } /// &lt;summary&gt; /// Removes first occurence of a element with a specified key and value. /// &lt;/summary&gt; /// &lt;param name="key"&gt;The key of the element to remove.&lt;/param&gt; /// &lt;param name="value"&gt;The value of the element to remove.&lt;/param&gt; /// &lt;returns&gt;true if the a element is removed; false if the key or the value were not found.&lt;/returns&gt; public bool Remove(TKey key, TValue value) { List&lt;TValue&gt; valueList; if (TryGetValue(key, out valueList)) { if (valueList.Remove(value)) { if (valueList.Count == 0) { Remove(key); } return true; } } return false; } /// &lt;summary&gt; /// Removes all occurences of elements with a specified key and value. /// &lt;/summary&gt; /// &lt;param name="key"&gt;The key of the elements to remove.&lt;/param&gt; /// &lt;param name="value"&gt;The value of the elements to remove.&lt;/param&gt; /// &lt;returns&gt;Number of elements removed.&lt;/returns&gt; public int RemoveAll(TKey key, TValue value) { List&lt;TValue&gt; valueList; int n = 0; if (TryGetValue(key, out valueList)) { while (valueList.Remove(value)) { n++; } if (valueList.Count == 0) { Remove(key); } } return n; } /// &lt;summary&gt; /// Gets the total number of values contained in the MultiMap. /// &lt;/summary&gt; public int CountAll { get { int n = 0; foreach (List&lt;TValue&gt; valueList in Values) { n += valueList.Count; } return n; } } /// &lt;summary&gt; /// Determines whether the MultiMap contains a element with a specific key / value pair. /// &lt;/summary&gt; /// &lt;param name="key"&gt;Key of the element to search for.&lt;/param&gt; /// &lt;param name="value"&gt;Value of the element to search for.&lt;/param&gt; /// &lt;returns&gt;true if the element was found; otherwise false.&lt;/returns&gt; public bool Contains(TKey key, TValue value) { List&lt;TValue&gt; valueList; if (TryGetValue(key, out valueList)) { return valueList.Contains(value); } return false; } /// &lt;summary&gt; /// Determines whether the MultiMap contains a element with a specific value. /// &lt;/summary&gt; /// &lt;param name="value"&gt;Value of the element to search for.&lt;/param&gt; /// &lt;returns&gt;true if the element was found; otherwise false.&lt;/returns&gt; public bool Contains(TValue value) { foreach (List&lt;TValue&gt; valueList in Values) { if (valueList.Contains(value)) { return true; } } return false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload