Exemplo n.º 1
0
        //  when encountering the same file name, create a file name with a index count addendum
        public bool CreateForWriting()
        {
            try
            {
                int i = 1;
                while (File.Exists(filename))
                {
                    ConstructFullPathName("_" + i.ToString("X2")); //a simple counter
                    i++;
                }

                if (log != null)
                {
                    log.TraceEvent(LogLevels.Info, 111, "Creating new output file: " + filename);
                }

                string path = Path.GetDirectoryName(filename);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                stream = File.Create(filename);
                writer = new StreamWriter(stream);// , System.Text.Encoding.Unicode);
                return(true);
            }
            catch (Exception e)
            {
                if (log != null)
                {
                    log.TraceException(e);
                }
                return(false);
            }
        }
Exemplo n.º 2
0
        public void ShowWB()
        {
            try
            {
#if EXCEL
                if (target == null)
                {
                    target = new Excel.Application();
                    target.Workbooks.Add();                     // add a new empty WB
                    target.Visible = true;                      // pop it up to the front, really annoying, in the traditional Windows way!
                }
#endif
            }
            catch (Exception e)
            {
                ctrllog.TraceException(e);
            }
        }
Exemplo n.º 3
0
 public static bool ExcelPresent(LMLoggers.LognLM optlog = null)
 {
     try
     {
         if (Type.GetTypeFromProgID("Excel.Application") != null)
         {
             return(true);
         }
     }
     catch (Exception e)
     {
         if (optlog != null)
         {
             optlog.TraceException(e);
         }
     }
     return(false);
 }