Question: C# Windows form app I have errors that i do not understand. Can someone please help me fix the issue. Im using the dateTimePicker to

C# Windows form app

I have errors that i do not understand. Can someone please help me fix the issue. Im using the dateTimePicker to grab its dates and convert them to strings and get the dates between and all store them in a list. Once in the datesbetween list im using them to filter files in a directory by the file name which is the date (ex. 20180323_mercedes.csv). I need help with following errors.

List DatesBetween(DateTime earliestDate, DateTime latestDate) A local or parameter named 'earliestDate' cannot be declared in this scope because that name is used in an enclosing local scope to defined a local or parameter A local or parameter named 'latestDate' cannot be declared in this scope because that name is used in an enclosing local scope to defined a local or parameter return allDates.ToString(); Cannot implicitly convert type 'string' to 'System.Collections.Generic.List'

********************************************************************************************************** syntax :

private void button2_Click(object sender, EventArgs e) { string earliestdate = dateTimePicker1.Value.ToString("yyyyMMdd"); string latestdate = dateTimePicker2.Value.ToString("yyyyMMdd"); DateTime earliestDate = DateTime.ParseExact(earliestdate, "yyyyMMdd", CultureInfo.InvariantCulture); DateTime latestDate = DateTime.ParseExact(latestdate, "yyyyMMdd", CultureInfo.InvariantCulture);

List DatesBetween(DateTime earliestDate, DateTime latestDate) { List allDates = new List(); for (DateTime date = earliestDate; date <= latestDate; date = date.AddDays(1)) allDates.Add(date); return allDates.ToString(); } List fileDirectories = new List();

if (checkedListBox1.GetItemCheckState(0) == CheckState.Checked) { if (checkedListBox2.GetItemCheckState(0) == CheckState.Checked) { fileDirectories.Add("...................") } else if (checkedListBox2.GetItemCheckState(1) == CheckState.Checked) { fileDirectories.Add("...................");

} else if (checkedListBox1.GetItemCheckState(2) == CheckState.Checked) {......} foreach (string selectedPath in fileDirectories) { string[] level1 = Directory.GetFiles(selectedPath, DatesBetween(earliestDate, latestDate) + ".csv", SearchOption.AllDirectories); foreach (string level2 in level1) { //Construct.pathList.Add(level2);

....................................................

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!