Exemple #1
0
        public static void LogDetails(Context context, string text)
        {
            File path = context.GetExternalFilesDir(null);
            File file = new File(path, "UEFuel.txt");

            if (!file.Exists())
            {
                try
                {
                    file.CreateNewFile();
                }
                catch { }
            }
            try
            {
                BufferedWriter buf = new BufferedWriter(new FileWriter(file, true));
                buf.Append(text);
                buf.NewLine();
                buf.Close();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        private static void logMsg(string text)
        {
            string path = "/storage/emulated/0/logCsharp.txt";

            Java.IO.File logFile = new Java.IO.File(path);
            //File logFile = new File("sdcard/log.file");
            if (!logFile.Exists())
            {
                try
                {
                    // logFile.Mkdir();
                    logFile.CreateNewFile();
                }
                catch (Java.IO.IOException e)
                {
                    // TODO Auto-generated catch block
                    e.PrintStackTrace();
                }
            }
            try
            {
                //BufferedWriter for performance, true to set append to file flag
                BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
                buf.Append(text);
                buf.NewLine();
                buf.Close();
            }
            catch (Java.IO.IOException e)
            {
                // TODO Auto-generated catch block
                e.PrintStackTrace();
            }
        }
Exemple #3
0
        private static void logMsg(string text)
        {
            //string path = "/storage/emulated/0/logsX.txt";
            //var path1 = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
            //System.IO.File.Create(path);

            //Java.IO.File sdCard = Android.OS.Environment.ExternalStorageDirectory;
            //Java.IO.File dir = new Java.IO.File(sdCard.AbsolutePath);
            //dir.Mkdirs();
            //Java.IO.File file = new Java.IO.File(dir, "iootext.txt");
            //if (!file.Exists())
            //{
            //    file.CreateNewFile();
            //    file.Mkdir();
            //    FileWriter writer = new FileWriter(file);
            //    // Writes the content to the file
            //    writer.Write("");
            //    writer.Flush();
            //    writer.Close();
            //}

            string path = "/storage/emulated/0/logCsharp.txt";

            Java.IO.File logFile = new Java.IO.File(path);
            //File logFile = new File("sdcard/log.file");
            if (!logFile.Exists())
            {
                try
                {
                    // logFile.Mkdir();
                    logFile.CreateNewFile();
                }
                catch (Java.IO.IOException e)
                {
                    // TODO Auto-generated catch block
                    e.PrintStackTrace();
                }
            }
            try
            {
                //BufferedWriter for performance, true to set append to file flag
                BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
                buf.Append(text);
                buf.NewLine();
                buf.Close();
            }
            catch (Java.IO.IOException e)
            {
                // TODO Auto-generated catch block
                e.PrintStackTrace();
            }
        }
Exemple #4
0
        public static void LogDetails(Context context, string text)
        {
            File path = context.GetExternalFilesDir(null);
            File file = new File(path, "UECrusher.txt");

            if (!file.Exists())
            {
                try
                {
                    file.CreateNewFile();
                }
                catch { }
            }
            try
            {
                BufferedWriter buf = new BufferedWriter(new FileWriter(file, true));
                buf.Append(text);
                buf.NewLine();
                buf.Close();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            //int length = (int)file.Length();
            //byte[] bytes = new byte[length];
            //if (file.Exists())
            //{
            //    FileInputStream input = new FileInputStream(file);
            //    try
            //    {
            //        input.Read(bytes);
            //    }
            //    finally
            //    {
            //        input.Close();
            //    }
            //}

            //String actual = Encoding.ASCII.GetString(bytes);

            //FileOutputStream stream = new FileOutputStream(file);
            //try
            //{
            //    stream.Write(Encoding.ASCII.GetBytes(actual + "\n" + message));
            //}
            //finally
            //{
            //    stream.Close();
            //}
        }
Exemple #5
0
        public void Log(string logMessage)
        {
            if (logFile == null)
            {
                logFile = GetLogFile();
            }
            FileWriter     fileWriter     = new FileWriter(logFile, true);
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            DateTime       currentTime    = new DateTime(DateTime.Now.Ticks);
            string         currentlogtime = DateTime.Now.ToString() + " " + GetVersion();

            bufferedWriter.Append(currentlogtime + ": " + logMessage);
            bufferedWriter.NewLine();
            bufferedWriter.Flush();
            bufferedWriter.Close();
        }