void ExportTo_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; List <object> args = e.Argument as List <object>; ArrayList items = args[0] as ArrayList; EXPORTS format = (EXPORTS)args[1]; string tempListFilename; switch (format) { case EXPORTS.EXCEL: tempListFilename = CreateUniqueFilename(MOG_ControllerProject.GetUser().GetUserToolsPath(), "AssetList.slk"); break; case EXPORTS.TEXT: tempListFilename = CreateUniqueFilename(MOG_ControllerProject.GetUser().GetUserToolsPath(), "AssetList.txt"); break; default: tempListFilename = ""; break; } // Clear out any previous temp file if (DosUtils.FileExist(tempListFilename)) { DosUtils.FileDelete(tempListFilename); } for (int i = 0; i < items.Count; i++) { ListViewItem item = items[i] as ListViewItem; string message = "Adding:\n" + " " + item.SubItems[(int)ASSET_LIST.NAME].Text; worker.ReportProgress(i * 100 / items.Count, message); string text = item.SubItems[(int)ASSET_LIST.NAME].Text + "\t" + item.SubItems[(int)ASSET_LIST.CLASSIFICATION].Text + "\t" + item.SubItems[(int)ASSET_LIST.PLATFORM].Text + "\t" + item.SubItems[(int)ASSET_LIST.VERSION].Text + "\t" + item.SubItems[(int)ASSET_LIST.SIZE].Text + "\t" + item.SubItems[(int)ASSET_LIST.OWNER].Text; switch (format) { case EXPORTS.EXCEL: DosUtils.AppendTextToSlkFile(tempListFilename, text); break; case EXPORTS.TEXT: DosUtils.AppendTextToFile(tempListFilename, text + "\r\n"); break; default: break; } } if (format == EXPORTS.EXCEL) { DosUtils.FileCloseSlk(tempListFilename); } e.Result = tempListFilename; }