当遇到异常时,将时间戳提前一天
本文关键字:时间戳 前一天 遇到 异常 | 更新日期: 2023-09-27 17:59:08
在我的代码中,我可以从文件夹中删除日期文件。
但是日期必须出现在某些*.dat
文件中,否则不会发生任何事情。
有些日子不包括在这些文件中;例如,节假日被跳过。
在这种情况下,我遇到了一个问题。
那么,如果我在其中一天,失败后如何才能晋级第二天呢?
private void button1_Click(object sender, EventArgs e)
{
string Destinationdead = "C:''test''test1";
string todaysDate;
todaysDate = dateTimePicker1.Text;
int FinalDate4 = 0;
BLWriterClass writerdelete1 = new BLWriterClass();
writerdelete1.OpenDirectory(Destinationdead);
writerdelete1.OpenSecurityBySymbol(SecSymbol);
FinalDate4 = int.Parse(todaysDate);
{
try
{
writerdelete1.OpenDirectory(Destinationdead);
writerdelete1.OpenSecurityBySymbol(SecSymbolbol);
FinalDate4 = int.Parse(todaysDate);
writerdelete1.OpenDirectory(Destinationdead);
writerdelete1.OpenSecurityBySymbol(SecSymbol);
int idate = Convert.ToInt32(dateTimePicker1.Text);
int itodate = Convert.ToInt32(dateTimePicker2.Text);
writerdelete1.DeleteSecRecords(idate, itodate);
}
catch (Exception)
{
}
}
writerdelete1.CloseSecurity();
writerdelete1.CloseDirectory();
}
问题出在DeleteSecRecords
方法中。
谷歌没有显示这个名字的点击率,所以没有办法查看它来进一步分析问题。
编辑:啊,我理解你的要求。每当遇到异常时,这将持续到第二天,直到没有可能的天数。
int idate = Convert.ToInt32(dateTimePicker1.Text);
int itodate = Convert.ToInt32(dateTimePicker2.Text);
while (idate <= itodate) {
try
{
writerdelete1.OpenDirectory(Destinationdead);
writerdelete1.OpenSecurityBySymbol(SecSymbolbol);
FinalDate4 = int.Parse(todaysDate);
writerdelete1.OpenDirectory(Destinationdead);
writerdelete1.OpenSecurityBySymbol(SecSymbol);
writerdelete1.DeleteSecRecords(idate, itodate);
break;
}
catch (Exception)
{
idate += 60 * 60 * 24; // advance by one day
continue;
}
}