여기에 약간 문제가 있습니다. 나는 그 파일들이 특정 크기 제한을 초과했다는 것을 사용자에게 알리는 전자 메일을 통해 파일 이름 목록을 보내는 응용 프로그램을 가지고 있습니다. 하지만 지금은 파일 이름뿐 아니라 파일 크기도 보내주기를 바랍니다. 이메일에 파일 크기를 첨부 할 수 있습니다. 하지만 내 문제는 그것이 표시되는 방식입니다. 나는 같이 표시 할 :두 목록을 이메일로 나란히 보냅니 까?
THE FILES :
filename1 = filesize1
filename2 = filesize2
filename3 = filesize3
..
..
..
HAS REACHED ITS LIMITS!
그러나 이메일에 내 현재의 표시 형식과 같은 것입니다 :
THE FILES :
filename1
filename2
filename3
filesize1
filesize2
filesize3
HAS REACHED ITS LIMITS!
을 그리고 지금은 처음처럼 표시 형식을 변경하는 방법을 모르겠어요. 어떤 도움이라도 대단히 감사하겠습니다.
private void Form1_Load(object sender, EventArgs e)
{
count = 0;
timer = new Timer();
timer.Interval = 1000;
timer.Tick += new EventHandler(timer1_Tick);
timer.Start();
System.Collections.Generic.List<string> files = new List<string>();
System.Collections.Generic.List<string> files1 = new List<string>();
//List<string> s1 = System.IO.Directory.GetFiles(@"C:\Documents and Settings\Administrator\Desktop\test", "*.*", SearchOption.AllDirectories).ToList<string>();
List<string> s1 = System.IO.Directory.GetFiles(@"F:\gdimaging\data", "*.*", SearchOption.AllDirectories).ToList<string>();
s1.AddRange(System.IO.Directory.GetFiles(@"F:\hios\DATA", "*.*", SearchOption.AllDirectories).ToList<string>());
s1.AddRange(System.IO.Directory.GetFiles(@"F:\imgviewer\data", "*.*", SearchOption.AllDirectories).ToList<string>());
s1.AddRange(System.IO.Directory.GetFiles(@"F:\newcnas\data", "*.*", SearchOption.AllDirectories).ToList<string>());
s1.AddRange(System.IO.Directory.GetFiles(@"F:\newpod\data", "*.*", SearchOption.AllDirectories).ToList<string>());
s1.AddRange(System.IO.Directory.GetFiles(@"F:\OMS\data", "*.*", SearchOption.AllDirectories).ToList<string>());
s1.AddRange(System.IO.Directory.GetFiles(@"F:\WEBIMG", "*.*", SearchOption.AllDirectories).ToList<string>());
dt.Columns.Add("File_Name");
dt.Columns.Add("File_Type");
dt.Columns.Add("File_Size");
dt.Columns.Add("Create_Date");
foreach (string s in s1)
{
try
{
FileInfo info = new FileInfo(s);
FileSystemInfo sysInfo = new FileInfo(s);
dr = dt.NewRow();
dr["File_Name"] = sysInfo.Name;
dr["File_Type"] = sysInfo.Extension;
dr["File_Size"] = (info.Length/1024).ToString();
dr["Create_Date"] = sysInfo.CreationTime.Date.ToString("dd/MM/yyyy");
dt.Rows.Add(dr);
if ((info.Length/1024) > 1500000)
{
MyFiles = new Dictionary<string, string>();
//files.Add(sysInfo.Name.ToString());
//files1.Add(info.Length.ToString());
//arr = string.Join("<br/>", files.ToArray());
//arr1 = string.Join("<br/>", files1.ToArray());
MyFiles.Add(sysInfo.Name.ToString(), info.Length.ToString());
}
if (dt.Rows.Count > 0)
{
dataGridView1.DataSource = dt;
}
}
catch (UnauthorizedAccessException ex)
{
MessageBox.Show("Error : " + ex.Message);
continue;
}
}
if (arr != null)
{
///Basic Email message
MailMessage mailMessage = new MailMessage();
// Email to send to
mailMessage.To.Add(new MailAddress("[email protected]"));
mailMessage.To.Add(new MailAddress("[email protected]"));
//set subject
mailMessage.Subject = "FILE SIZE WARNING MESSAGE";
//set body
//mailMessage.Body = "THE FILES : <br/><br/>" + arr + arr1 + "<br/><br/> HAS REACH ITS SIZE LIMIT!!";
mailMessage.Body = "THE FILES : <br/><br/>";
foreach (string key in MyFiles.Keys)
{
mailMessage.Body += key + " = " + MyFiles[key] + "<br/>";
mailMessage.Body += "<br/> HAS REACHED ITS SIZE LIMIT!";
}
mailMessage.IsBodyHtml = true;
mailMessage.From = new MailAddress("************", "Shahrul Nizam");
//Identify the credentials to login to the gmail account
string sendEmailsFrom = "**********";
string sendEmailsFromPassword = "**********";
NetworkCredential cred = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword);
SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mailClient.UseDefaultCredentials = false;
//mailClient.Timeout = 20000;
mailClient.UseDefaultCredentials = true;
mailClient.Credentials = cred;
mailClient.Send(mailMessage);
//MessageBox.Show("Email Notification Sent!");
//MessageBox.Show(fileList.ToString() + "overlimit!!");
}
}
private void timer1_Tick(object sender, EventArgs e)
{
count++;
if (count == 600)
{
count = 0;
timer.Stop();
Application.Restart();
}
}
현재 너무 큰 파일 목록을 어떻게 생성하고 있습니까? – sarnold
자, 자. 나는 오늘 밤에 더 완벽한 대답을 생각할 수 없다. 너무 늦었다. 그것이 도움이된다면 받아 들여지는 대답을하는 것이 좋은 생각입니다 -> 그것은 당신의 속도를 향상시키고 더 많은 사람들이 (아마도 나보다 나은) 대답 할 의향이있을 것입니다 : –