0

Hi,

I'm creating a program were logs files in a certain directory are presented in a table format.

My issue here is, I created a filter option in which the user can filter data available in a particular year and month.

I currently retrieved all the file dates and its in format (2014-08-01).
now I would like to store the values in the format in the below example and then populate the year and month in the dropdown:

2014
   - May
   - Jun

2015
    - Apr
    - May    

Thus, mainitaining the year and month relation intact.

I request your help in letting me know which data structure would help me achieve it.

Thanks in advance.
Karthikprs

Edited by karthikprs

4
Contributors
3
Replies
32
Views
4 Weeks
Discussion Span
Last Post by geniusvishal
0

As for storing your data a 2D dictionary would work:

Dictionary<string,Dictionary<string,FileInfo[]>> fileTree;

The outer dictionary would have the year as the key. Each year then would contain a dictionary with the month as the key. Each month would then have an array of FileInfo objects referring to the files for that year and month.

To access the specific array simply index by the year and the month:

fileTree["2014"]["Mar"];

At this point populating a combobox is a simple matter of assigning the array as the data source to the combobox

0

Are you looking for some database solution.

Yes you can make four fields in Database Year, Month, Filename, Filepath. You can increase the field to five if you want to increase the filtering option based upon date.

//You can pass your custom date instead of Current Day.
String sDate = DateTime.Now.ToString();
DateTime datevalue = (Convert.ToDateTime(sDate.ToString()));

String dy = datevalue.Day.ToString();
String mn = datevalue.Month.ToString();
String yy = datevalue.Year.ToString();

Afterwards you can bind these Data in a treeview control using this method from the Database:

https://www.aspsnippets.com/Articles/Display-Directory-Folder-structure-using-ASPNet-TreeView-control-in-C-and-VBNet.aspx

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.