Beispiel #1
0
        internal static bool ExportToFile(List <Kisayol> list, string saveFile)
        {
            bool result = false;

            try
            {
                //KisayolAdi
                //Yol
                using (StreamWriter sWriter = new StreamWriter(new FileStream(saveFile, FileMode.OpenOrCreate))
                {
                    AutoFlush = true
                })
                {
                    // sWriter.AutoFlush = true;
                    sWriter.Write("{0}\t", "KisayolAdi");
                    sWriter.Write("{0}\t", "Yol");
                    sWriter.Write("\n");

                    foreach (Kisayol k in list)
                    {
                        sWriter.Write("{0}\t", ObjectUtility.ToStr(k.KisayolAdi).Replace("\n", " "));
                        sWriter.Write("{0}\t", ObjectUtility.ToStr(k.Yol).Replace("\n", " "));
                        sWriter.Write("\n");
                    }
                }
                result = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }
Beispiel #2
0
        bool ExportToFile(List <Kisayol> list)
        {
            bool res = false;

            try
            {
                svFlDialog = new SaveFileDialog();
                DialogResult dr = svFlDialog.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK || dr == System.Windows.Forms.DialogResult.Yes)
                {
                    string fileName = svFlDialog.FileName;
                    if (ObjectUtility.ToStr(fileName).Replace(" ", "").Length == 0)
                    {
                        MessageUtil.Warn("Save File Name can not be empty.");
                        return(res);
                    }

                    if (fileName.EndsWith(".xls") == false)
                    {
                        fileName += ".xls";
                    }

                    res = ExportManager.ExportToExcel(list, fileName);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                svFlDialog = null;
            }

            return(res);
        }