개인 공허에서 정보를 가져 와서 다른 사람에게 넣고 싶습니다.이 작업을 수행해야하며 동일한 섹션에서 실행할 수 없습니다. 그 코드는 내가 원하는 코드로 작동하지 않을 것이다. 여기에 dlg2.selectedPath가 작동하지 않는 코드가 있습니다.이 버튼은 개인 무효 버튼에서 인식됩니다.개인 공백에서 정보를 가져 와서 다른 사람에게 넣는 방법
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog dlg2 = new FolderBrowserDialog();
if (dlg2.ShowDialog() == DialogResult.OK)
//do whatever with dlg.SelectedPath
{
backgroundWorker1.RunWorkerAsync();
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
DirectoryInfo source = new DirectoryInfo(dlg.SelectedPath);
DirectoryInfo target = new DirectoryInfo(dlg2.SelectedPath);
DirectoryInfo dir = new DirectoryInfo(dlg.SelectedPath);
FileInfo[] fis = dir.GetFiles("*", SearchOption.AllDirectories);
foreach (FileInfo fi in fis)
{
if (fi.LastWriteTime.Date == DateTime.Today.Date)
{
File.Copy(fi.FullName, target.FullName + "\\" + fi.Name, true);
}
}
}
어떤 도움을 주실 수 있습니다.
: 당신의
DoWork
핸들러에서는DoWorkEventArgs
인스턴스에서 값을 얻을 수 있습니다. 관련 : http://stackoverflow.com/questions/4899281/c-backgroundworker-wont-work-with-the-code-i-want-it-to-do –이들은 코드의 동일한 조각에 대한 두 가지 다른 쿼리입니다 내가 가진 각각의 문제를 해결하기 위해 정보를 얻었습니다. – bobthemac