コード例 #1
0
        void listWriteLoop()
        {
            int count = 0;

            try
            {
                StreamWriter writer = new StreamWriter(m_exportFileName);

                // first line in file
                bool GPSData = m_ExportList[0].GPSOnly;

                if (!GPSData)
                {
                    writer.WriteLine("match likelyhood, scanned number, time, camera name, image path");
                }

                int totalCount = m_ExportList.Count();

                lock (m_ExportList)
                {
                    foreach (EXPORT_DATA item in m_ExportList)
                    {
                        writer.WriteLine(item.line);

                        if (!GPSData)  // copy the image file over to the export directory
                        {
                            FileInfo fi = new FileInfo(item.filepath);

                            string fileNameOnly = fi.Name;

                            string newPathName = m_ExportDirectory + "\\" + fileNameOnly;

                            File.Copy(item.filepath, newPathName, true);
                        }

                        count++;

                        if (count % 100 == 0 || count == totalCount)
                        {
                            m_ExportStatusForm.SetProgress(count, totalCount);
                        }

                        if (m_KillThreads)
                        {
                            break;
                        }
                    }
                    writer.Close();
                    if (m_ExportStatusForm.Visible)
                    {
                        m_ExportStatusForm.Close();
                    }
                    m_ExportList = null;
                }
            }
            catch (Exception ex)
            {
//                MessageBox.Show("file IO exception writing file " + m_exportFileName + "\n\r operation failed \n\r" + ex.Message);
                m_Log.Trace(ex, ErrorLog.LOG_TYPE.INFORMATIONAL);
                //m_ExportInProgress = false;
            }

            m_ExportInProgress = false;
        }