简体   繁体   中英

cannot implicity convert type 'string' to 'system,DateTime'

i am creating a project . i want to download the files from ftp . i can download it but only by todays date in dateTimePicker1. it only downloads systems date. my code is

txtSelectedDate.Text = DateTime.Now.ToString("yyyyMMdd");
dateTimePicke1.Value = DateTime.NoW;

can anyone say me how to download files by selecting date in dateTimePicker1 not by Current date. thanks in advance.

Select a different date on the control "dateTimePicker1" use the code below:

txtSelectedDate.Text = dateTimePicker1.Value;

or

txtSeletedDate.Text = dateTimePicker1.Value.ToShortDateString();

DateTimePicker allows you to change the date you are using and you should not use DateTime.Now, you shall assign the selected date to your text property.

I believe what you are looking for is the DateTime.ParseExact command, like so:

DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm tt", null);

If you assign that to your dateTimePicker1 you will be able to give it any date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM