...它只是停止。它不通過所有它應該通過代碼...代碼是越來越取消
在代碼下面它只是停止在String gName = comboBox1.SelectedItem.ToString();
沒有任何錯誤沒有..下面的代碼根本不會得到運行..我測試了這個在ZipFile pack = new ZipFile();
放置斷點...斷點不會被觸發...我已經通過我的代碼一遍又一遍......我無法找出爲什麼它是...
背景工人:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
String appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString();
String gpsPath = appDataFolder + "/GameProfileSaver";
String userDir = gpsPath + "/profiles/" + currentUserLabel.Text;
XmlDocument doc = new XmlDocument();
doc.Load(userDir + "\\games.xml");
String gName = comboBox1.SelectedItem.ToString();
ZipFile pack = new ZipFile();
foreach (XmlNode node in doc.SelectNodes("//games/game[gameName='" + gName + "']/Files/file"))
{
try
{
if (!Directory.Exists(userDir + "\\" + gName))
{
Directory.CreateDirectory(userDir + "\\" + gName);
}
pack.AddFile(node.InnerText);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
pack.Save(userDir + "\\" + gName);
}
我現在找不到任何具體的參考資料,但是IIRC'DoWork'無法訪問表單的元素。嘗試把'String gName = comboBox1.SelectedItem.ToString();'放在try/catch中,看看會發生什麼 – CDspace