 |
|
ผมเขียนฟังก์ชั่น return string โดยใช้ delegate แต่มัน error รบกวนดูให้หน่อยครับ |
|
 |
|
|
 |
 |
|
ได้แล้วครับ อิอิ
Code (C#)
public delegate string CheckViewSourceCallback(int idx);
private string CheckNameViewSource(int idx)
{
if (this.listViewSource.InvokeRequired)
{
CheckViewSourceCallback clv = new CheckViewSourceCallback(CheckNameViewSource); //ตรงที่ขึ้น Error
return (string)Invoke(clv, new object[] { idx });
}
else
{
return (string)listViewSource.Items[idx].Text;
}
}
public delegate string CheckViewDestiCallback(int idx);
private string CheckNameViewDesti(int idx)
{
if (this.listViewDesti.InvokeRequired)
{
CheckViewDestiCallback clv = new CheckViewDestiCallback(CheckNameViewDesti); //ตรงที่ขึ้น Error
return (string)Invoke(clv, new object[] { idx });
}
else
{
return (string)listViewDesti.Items[idx].Text;
}
}
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
if (listViewDesti.Items.Count == 0)
{
ClAllsync syncCopy = new ClAllsync();
syncCopy.CopyFolder(txtSource.Text, txtDesti.Text);
}
else
{
ClAllsync newCopy = new ClAllsync();
newCopy.CopyNewFiles(txtSource.Text, txtDesti.Text);
for (int i = 0; i < listViewSource.Items.Count; i++)
{
string namefilesource = Path.GetFileName(CheckNameViewSource(i));
DateTime datename_s = File.GetLastWriteTime(CheckNameViewSource(i));
for (int j = i; i < listViewDesti.Items.Count; j++)
{
string namefiledest = Path.GetFileName(CheckNameViewDesti(j));
DateTime datename_d = File.GetLastWriteTime(CheckNameViewDesti(j));
if (namefilesource == namefiledest)
{
if (datename_s != datename_d)
{
File.Copy(CheckNameViewSource(i), CheckNameViewDesti(j), true);
Application.DoEvents();
}
else
{
break;
}
}
else
{
break;
}
break;
}
}
}
}
|
 |
 |
 |
 |
Date :
2011-04-29 13:19:38 |
By :
GhostLocal |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|