Esempio n. 1
0
        public static string SaveExceptionData(Exception ex, string exDir, bool noThrow = true)
#endif
        {
            try
            {
#if NETFX_CORE
                StorageFolder f = await FileTools.CreateDirectory(exDir);
#else
                FileTools.CreateDirectory(exDir);
#endif

#if NETFX_CORE
                ExceptionDetail ed     = new ExceptionDetail(ex);
                string          exPath = FileTools.GetSequentialFileName(f, "Exception", ".xml");
                StorageFile     target = await FileTools.CreateFile(exPath, true);

                await FileTools.WriteAllText(target, ed.ToString());
#else
                ExceptionDetail ed     = new ExceptionDetail(ex);
                string          exPath = FileTools.GetSequentialFileName(exDir, "Exception", ".xml");
                ed.ToXML().Save(exPath);
#endif

                return(exPath);
            }
            catch (Exception)
            {
                if (!noThrow)
                {
                    throw;
                }
                // EMPTY:  This can't fail!
                return(null);
            }
        }