Hi
I have some files in which date and time is mentioned. I want to sort the files .In very first line of the file date and time is mentioned. Files must be sorted accordingly.
Assist me for the proper code.
regards
Kritika
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Aug 16, 2013, 4:14 AM
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 3:54 AM
Thanks
Iftikar HussainPosted Aug 16, 2013, 3:52 AM
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 3:47 AM
Iftikar HussainPosted Aug 16, 2013, 3:31 AM
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 3:16 AM
Iftikar HussainPosted Aug 16, 2013, 3:14 AM
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 3:11 AM
kritika RanaPosted Aug 16, 2013, 3:09 AM
Iftikar HussainPosted Aug 16, 2013, 3:04 AM
var filePath = fileInfo.FilePath;
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 3:01 AM
try
{
foreach (var fileInfo1 in resultFiles)
{
var filePath1 = fileInfo1.FullName;
using (var textFile = File.OpenText(filePath1))
{
SendMail(textFile.ReadToEnd());
}
}
MessageBox.Show("Email Send Successfully");
}
catch (Exception ex)
{
MessageBox.Show( ex.ToString());
}
Iftikar HussainPosted Aug 16, 2013, 2:51 AM
Regards,
Iftikar
kritika RanaPosted Aug 16, 2013, 2:46 AM
private static DateTime GetDateValue(string fileContent, string fileName)
{
var temp = fileContent.Replace(fileName, string.Empty);
temp = temp.Replace("APU-PERF.VDR", string.Empty);
temp = temp.Replace("?", string.Empty);
temp = temp.Trim();
var tempArray = temp.Split(' ');
var tempDate = tempArray[2];
var tempTime = tempArray[3];
var tempDay = Convert.ToInt16(temp.Substring(5, 2));
var tempMonth = Convert.ToInt32(GetMonth(tempDate.Substring(2, 3)));
var tempYear = Convert.ToInt32(tempDate.Substring(0, 2));
var tempTimeArray = tempTime.Split(':');
var tempHr = Convert.ToInt16(tempTimeArray[0]);
var tempMint = Convert.ToInt16(tempTimeArray[1]);
var tempSecond = Convert.ToInt16(tempTimeArray[2]);
var dt = new DateTime(tempDay, tempMonth, tempYear, tempHr, tempMint, tempSecond);
return dt;
}
Iftikar HussainPosted Aug 16, 2013, 2:28 AM
kritika RanaPosted Aug 16, 2013, 2:26 AM
Iftikar HussainPosted Aug 16, 2013, 2:26 AM
";
Regards,
Iftikar
Iftikar HussainPosted Aug 16, 2013, 2:24 AM
kritika RanaPosted Aug 16, 2013, 2:07 AM
Iftikar HussainPosted Aug 16, 2013, 2:06 AM
kritika RanaPosted Aug 16, 2013, 2:01 AM
private void button7_Click(object sender, EventArgs e)
{
string path = @"D:\vikas";
DirectoryInfo dinfo = new DirectoryInfo(path);
var files = dinfo.GetFiles("*").OrderBy(s => s.LastWriteTime).ToList();
StringBuilder sb = new StringBuilder();
try
{
foreach (var fileInfo in files)
{
var filePath = fileInfo.FullName;
using (var textFile = File.OpenText(filePath))
{
SendMail(textFile.ReadToEnd());
}
}
MessageBox.Show("Email Send Successfully");
}
catch (Exception ex)
{
MessageBox.Show("Mail Not Send Check for error",ex.ToString ());
}
}
private void SendMail(string fileContent)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "Kritika");
mailMessage.To.Add("[email protected]");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
mailMessage.Body = fileContent+"
";
using (SmtpClient mailbox = new SmtpClient("smtp.gmail.com", 587))
{
mailbox.Credentials = new NetworkCredential("[email protected]", "mrsseema");
mailbox.EnableSsl = true;
mailbox.Send(mailMessage);
}
}
Iftikar HussainPosted Aug 16, 2013, 1:56 AM
kritika RanaPosted Aug 16, 2013, 1:53 AM
the highlighted value
kritika RanaPosted Aug 16, 2013, 1:52 AM
Iftikar HussainPosted Aug 16, 2013, 1:48 AM
R49-4002.049³ 13AUG14³ 11:26:52³ 13AUG14³ 11:26:49³ APU-PERF.VDR
kritika RanaPosted Aug 16, 2013, 1:47 AM
Iftikar HussainPosted Aug 16, 2013, 1:43 AM
kritika RanaPosted Aug 16, 2013, 1:42 AM
Iftikar HussainPosted Aug 16, 2013, 1:39 AM
and which one need to check?
R49-4002.049³ 13AUG14³ 11:26:52³ 13AUG14³ 11:26:49³ APU-PERF.VDR
kritika RanaPosted Aug 16, 2013, 1:38 AM
If you open the file which I have send u as attachment, date and time is mentioned in very first line of the file . I want to sort according to that date and time not as system date and time
Kritika
Iftikar HussainPosted Aug 16, 2013, 1:34 AM
kritika RanaPosted Aug 16, 2013, 1:33 AM
When you open the file in wordpad you will find in very first line date and time is mentioned.
I want the files to be sorted according to that date and time.
Hope you understand my query.
Regards
Kritika
kritika RanaPosted Aug 16, 2013, 1:30 AM
Again I have some new queries........
As my program is working properly but I want to sort the files according to date and time mentioned in the very first line of the files.
If possible then guide me completing the project.
I hereby attach sample files for your reference
Regards
Kritika
Iftikar HussainPosted Aug 16, 2013, 1:25 AM
I think you have done this in your last post.
Regards,
Iftikar