Example #1
0
        //TODO
        //IT will run in another thread
        //I will receive a XML, i must parse the commands and then put it in a temp file
        //Then i will try to execute it.
        static bool ExecCMD(string cmd_to_exec)
        {
            StreamWriter SW;

            SW = File.CreateText("c:\\sadan.vbs");
            SW.WriteLine(cmd_to_exec);
            //SW.WriteLine("This is second line");
            SW.Close();
            Process PScript = new Process();

            PScript.StartInfo.FileName  = "wscript.exe";
            PScript.StartInfo.Arguments = "c:\\sadan.vbs";
            PScript.EnableRaisingEvents = true;
            PScript.Exited += new EventHandler(processExited);

            try
            {
                PScript.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(true);
        }
Example #2
0
 //A thread is created so multiple users can use the server at the same time.
 //If there is a save file address then the dictionary is saved
 public void writeToFile()
 {
     lock (locker)
     {
         if (saveFile == null)
         {
             return;
         }
         try
         {
             StreamWriter SW;
             File.WriteAllText(saveFile, string.Empty);
             SW = File.AppendText(saveFile);
             foreach (var entry in Program.savedResults)
             {
                 SW.WriteLine("[{0}, {1}]", entry.Key, entry.Value.Trim());
             }
             SW.Close();
         }
         catch (Exception)
         {
             Console.WriteLine("Unable to write save file " + saveFile);
         }
     }
 }
Example #3
0
        //Line breaks are replaced with spaces'
        //The log entry is formatted correctly and gets printed to the console
        //The entry is then saved to the log file as long as the address is present.
        public void WriteToLog(string hostname, string message, string status)
        {
            if (message != null)
            {
                message = message.Replace("\r\n", " ");
            }

            string line = hostname + " - - " + DateTime.Now.ToString("'['dd'/'MM'/'yyyy':'HH':'mm':'ss zz00']'") + " \"" + message + "\" " + status;

            lock (locker)
            {
                Console.WriteLine(line);

                if (logFile == null)
                {
                    return;
                }
                try
                {
                    StreamWriter SW;
                    SW = File.AppendText(logFile);
                    SW.WriteLine(line);
                    SW.Close();
                }
                catch (Exception)
                {
                    Console.WriteLine("Unable to write log file " + logFile);
                }
            }
        }
        public void readArchive()
        {
            //this will read from the archive
            StreamReader SR;
            string       S;
            int          i = 0;

            SR = File.OpenText(@"the path here for the excel archive");

            S = SR.ReadToEnd();
            SR.Close();
            Console.WriteLine(S);
            string[] words = S.Split(';');
            Array.Sort(words);
            for (i = 0; i < words.Length; i++)
            {
                Console.WriteLine(words[i]);
            }

            //this will create the archive
            StreamWriter SW;

            SW = File.CreateText(@"the path here for the .txt");
            for (i = 0; i < words.Length; i++)
            {
                SW.WriteLine(words[i]);
            }
            SW.Close();
        }
Example #5
0
        /// <summary>
        /// purpose of this method is to maintain error log in text file.
        /// </summary>
        /// <param name="exx"></param>
        public static void Create_ErrorFile(Exception exx)
        {
            StreamWriter SW;

            if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
            {
                SW = File.CreateText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"));
                SW.Close();
            }
            using (SW = File.AppendText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
            {
                string[] str = new string[] { exx.Message == null?"":exx.Message.ToString(), exx.StackTrace == null?"":exx.StackTrace.ToString(),
                                              exx.InnerException == null?"":exx.InnerException.ToString() };
                for (int i = 0; i < str.Length; i++)
                {
                    SW.Write("\r\n\n");
                    if (str[i] == str[0])
                    {
                        SW.WriteLine("Exception Message:" + str[i]);
                    }
                    else if (str[i] == str[1])
                    {
                        SW.WriteLine("StackTrace:" + str[i]);
                    }
                    else if (str[i] == str[2])
                    {
                        SW.WriteLine("InnerException:" + str[i]);
                    }
                }
                SW.Close();
            }
        }
Example #6
0
    public static void Main()
    {
        StreamReader SR;

        SR = File.OpenText("C-large.in");
        string       S;
        StreamWriter SW;

        SW = File.CreateText("C.out");

        int N = int.Parse(SR.ReadLine());

        string ss = "welcome to code jam";

        for (int cc = 1; cc <= N; cc++)
        {
            S = SR.ReadLine();
            int l = S.Length;
            int[,] r = new int[l, 19];
            for (int i = 18; i >= 0; i--)
            {
                for (int j = 0; j < l; j++)
                {
                    if (S[j] == ss[i])
                    {
                        if (i == 18)
                        {
                            r[j, 18] = 1;
                        }
                        else
                        {
                            for (int k = j + 1; k < l; k++)
                            {
                                r[j, i] += r[k, i + 1];
                                r[j, i] %= 10000;
                            }
                        }
                    }
                }
            }

            int res = 0;
            for (int i = 0; i < l; i++)
            {
                res += r[i, 0];
            }
            res %= 10000;
            res += 10000;
            string rr = Convert.ToString(res);
            rr = rr.Substring(1);



            SW.WriteLine("Case #" + cc + ": " + rr);
            Console.WriteLine("Case #" + cc + ": " + rr);
        }
        SR.Close();

        SW.Close();
    }
        private void WriteChildParentChild(string childLine)
        {
            string parent = GetParent();

            SW.WriteLine(parent + ": " + childLine + ".");
            SW.WriteLine("   ");
        }
Example #8
0
        public static void DeleteInfoLog(string URL)
        {
            string       LogFilePath = System.Configuration.ConfigurationManager.AppSettings["LogFilePath"];
            StreamWriter SW;
            string       FileName = DateTime.Now.ToString("yy-MM-dd") + "_DeleteInfo.Log";
            string       FilePath = LogFilePath + FileName;

            try {
                if (!Directory.Exists(LogFilePath))
                {
                    Directory.CreateDirectory(LogFilePath);
                }
                if (!File.Exists(FilePath))
                {
                    SW = File.CreateText(FilePath);
                }
                else
                {
                    SW = File.AppendText(FilePath);
                }
                SW.WriteLine("==================================================删除信息日志信息====================================================");
                SW.WriteLine("删除时间:" + DateTime.Now.ToString());
                SW.WriteLine("信息地址:" + URL.ToString());
                SW.WriteLine("===================================================================================================================");
                SW.WriteLine(" ");
                SW.Close();
            }
            catch { }
        }
Example #9
0
        void WriteToLog(string text)
        {
            lock (Locker)
            {
                try
                {
                    StreamWriter SW;
                    if (LogPath == string.Empty)
                    {
                        LogPath = string.Format("{0}/../logs", System.IO.Directory.GetCurrentDirectory());

                        if (!System.IO.Directory.Exists(LogPath))
                        {
                            System.IO.Directory.CreateDirectory(LogPath);
                        }

                        string FileName = DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss_") + mDummyFileName;
                        LogPath += string.Format("/{0}.log", FileName);
                    }

                    SW = File.AppendText(LogPath);
                    SW.WriteLine(string.Format("{0}, {1}", DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"), text));
                    SW.Close();
                    SW.Dispose();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.Print(e.Message);
                    return;
                }
            }
        }
Example #10
0
        /// <summary>
        /// 类错误日志记录
        /// </summary>
        /// <param name="ex">错误</param>
        /// <param name="ErrClassName">发生错误的类名</param>
        public static void ErrLogWrite(Exception ex, string ErrClassName)
        {
            string       LogFilePath = System.Configuration.ConfigurationManager.AppSettings["LogFilePath"];
            StreamWriter SW;
            string       FileName = DateTime.Now.ToString("yy-MM-dd") + ".Log";
            string       FilePath = LogFilePath + FileName;

            try {
                if (!Directory.Exists(LogFilePath))
                {
                    Directory.CreateDirectory(LogFilePath);
                }
                if (!File.Exists(FilePath))
                {
                    SW = File.CreateText(FilePath);
                }
                else
                {
                    SW = File.AppendText(FilePath);
                }
                SW.WriteLine("==================================================页面错误信息====================================================");
                SW.WriteLine("错误时间:" + DateTime.Now.ToString());
                SW.WriteLine("错误类名:" + ErrClassName.ToString());
                SW.WriteLine("错误消息:" + ex.Message.ToString());
                SW.WriteLine("导致错误的应用程序或对象的名称:" + ex.Source.ToString());
                SW.WriteLine("堆栈内容:" + ex.StackTrace.ToString());
                SW.WriteLine("引发异常的方法:" + ex.TargetSite.ToString());
                SW.WriteLine("===================================================================================================================");
                SW.WriteLine(" ");
                SW.Close();
            }
            catch { }
        }
Example #11
0
        public static void WriteLogs(string LogText)
        {
            string       LogFilePath = System.Configuration.ConfigurationManager.AppSettings["LogFilePath"];
            StreamWriter SW;
            string       FileName = DateTime.Now.ToString("yy-MM-dd") + "_RunLog.Log";
            string       FilePath = LogFilePath + FileName;

            try {
                if (!Directory.Exists(LogFilePath))
                {
                    Directory.CreateDirectory(LogFilePath);
                }
                if (!File.Exists(FilePath))
                {
                    SW = File.CreateText(FilePath);
                }
                else
                {
                    SW = File.AppendText(FilePath);
                }
                //SW.WriteLine("==================================================日志信息====================================================");
                SW.WriteLine(LogText.ToString());
                //SW.WriteLine("==============================================================================================================");
                SW.Close();
            }
            catch { }
        }
        // 全てのメンバーを分析する
        static void AnalyzeMemberInfo(Type t, int nestLevel)
        {
            SWTabSpace(nestLevel);

            // クラス名名
            var gname = ReplaceCsToTs(t.Name);

            // Genericなら、
            var genericTypes = t.GetGenericArguments();
            var genlist      = GetGenericParameterTypeStringList(t);

            // メンバー名<Generic, ...>の形に
            if (genlist.Count > 0)
            {
                gname = gname + "<" + String.Join(", ", genlist) + ">";
            }

            SW.WriteLine("interface " + gname + " {");

            AnalyzeConstructorInfoList(t, nestLevel);
            AnalyzeFieldInfoList(t, nestLevel);
            AnalyzePropertyInfoList(t, nestLevel);
            AnalyzeEventInfoList(t, nestLevel);
            AnalyzeMethodInfoList(t, nestLevel);

            SWTabSpace(nestLevel);
            SW.WriteLine("}");
        }
            /// <summary>
            /// This writes a Log entry to the console and optionally to a file,
            /// trapping file write errors.
            /// </summary>
            /// <param name="hostName">name of host.</param>
            /// <param name="message">first input line sent from the client, holding useful info.</param>
            /// <param name="status">States if each attempt was OK or not.</param>
            public void WriteToLog(string hostName, string message, string status)
            {
                // Creates a line in the Common Log Format.
                string line = hostName + " - - " + DateTime.Now.ToString("'['dd'/'MM'/'yyyy':'HH':'mm':'ss zz00']'") + " \"" + message + " \"" + status;

                // Lock the file write to prevent concurrent threaded writes.
                lock (locker)
                {
                    Console.WriteLine(line);
                    if (logFile == null)
                    {
                        return;
                    }

                    // If no Log file exists after writing to console.
                    try
                    {
                        StreamWriter SW;
                        SW = File.AppendText(logFile);
                        SW.WriteLine(line);
                        SW.Close();
                    }
                    catch
                    {
                        // Catch any file write errors.
                        Console.WriteLine("Unable to write to the Log File: " + logFile);
                    }
                }
            }
    /// <summary>
    /// This writes a log entry to a console and optionally to the file
    /// </summary>
    /// <param name="hostname"></param>
    /// <param name="message"></param>
    /// <param name="status"></param>
    public void WriteToLog(string hostname, string message, string status)
    {
        //Creates line in common log format
        string line = hostname + " - - " + DateTime.Now.ToString("'['dd'/'MM'/'yyyy':'HH':'mm':'ss zz00']'") + " \"" + message + "\" " + status;

        //Lock the file write to prevent concurent threaded writes
        lock (locker)
        {
            Console.WriteLine(line);
            if (LogFile == null)
            {
                return;
            }
            //if no log file exist after writing to console
            try
            {
                StreamWriter SW;
                SW = File.AppendText(LogFile);
                SW.WriteLine(line);
                SW.Close();
            }
            catch
            {
                //Write an error with cathcing the file
                Console.WriteLine("Unable to Write Log File " + LogFile);;
            }
        }
    }
Example #15
0
        public override void ConsumeCCSRead(PacBioCCSRead read, BWAPairwiseAlignment aln, List <Variant> variants)
        {
            var aligned = aln == null ? "FALSE" : "TRUE";
            var end     = String.Join(",", read.MutationsTested.ToString(), read.MutationsApplied.ToString(),
                                      read.ProcessingTimeMS.ToString(), read.Barcode1.ToString(),
                                      read.Barcode2.ToString());

            string start = String.Join(",", read.Movie, read.HoleNumber.ToString(),
                                       read.SnrA.ToString(), read.SnrC.ToString(), read.SnrG.ToString(),
                                       read.SnrT.ToString(), aligned, read.ReadQuality.ToString(),
                                       read.AvgZscore.ToString(), read.Sequence.Count.ToString(), read.NumPasses.ToString(),
                                       read.ReadCountSuccessfullyAdded.ToString(), read.ReadCountBadZscore.ToString(),
                                       read.ReadCountAlphaBetaMismatch.ToString(),
                                       read.ReadCountOther.ToString());

            if (aln == null)
            {
                start = start + ",NA,NA,NA,NA,NA,NA," + end;
            }
            else
            {
                var indels = variants.Count(z => z.Type == VariantType.INDEL);
                var snps   = variants.Count(z => z.Type == VariantType.SNP);
                var total  = variants.Count;
                var length = aln.AlignedSAMSequence.RefEndPos - aln.AlignedSAMSequence.Pos;
                start = start + "," + String.Join(",", length.ToString(), aln.AlignedSAMSequence.Pos, total.ToString(), indels.ToString(), snps.ToString(),
                                                  aln.AlignedSAMSequence.RName, end);
            }
            SW.WriteLine(start);
        }
        public void WriteLog(double[] Probs, int NextStage, string Path)
        {
            StreamWriter SW;

            SW = File.AppendText(Path + @"\Log\WeightsLog.txt");
            SW.WriteLine("G = {0:G}", DateTime.Now);
            SW.WriteLine("*******************************");
            string probline = "Probabilities = ";

            foreach (double d in Probs)
            {
                probline += d.ToString();
                probline += ", ";
            }
            //SW.WriteLine("Probabilities = " + Probs[0].ToString() + ", " + Probs[1].ToString() + ", " + Probs[2].ToString());
            SW.WriteLine(probline);
            SW.WriteLine("Next Stage = " + NextStage.ToString());
            SW.WriteLine("Feedback = " + FPN.U.ToString());
            SW.WriteLine("*******************************");
            SW.WriteLine(W1comma);
            SW.WriteLine("*******************************");
            SW.WriteLine("");
            SW.WriteLine(W2comma);
            SW.WriteLine("*******************************");
            SW.WriteLine("");
            SW.WriteLine("");
            SW.Close();
        }
Example #17
0
        public void EscribirLog(string strTextoLog)
        {
            // VARIABLES
            StreamWriter SW;
            string       strFecha = Convert.ToString(System.DateTime.Now);


            // DETERMINA SI EL ARCHIVO DE LOG EXISTE
            if (File.Exists(Class1.strLogFile))
            {
                // ABRE EL ARCHIVO PARA EJECUTAR UNOS APPEND
                SW = File.AppendText(Class1.strLogFile);
            }
            else
            {
                // CREA UN ARCHIVO NUEVO DE LOG
                SW = File.CreateText(Class1.strLogFile);
            }


            if (Class1.strEscrituraLog == "")
            {
                SW.WriteLine("  NOMBRE ARCHIVO:    " + Class1.strFileName.Replace(" ", ""));
                SW.WriteLine("  FECHA DE LA CARGA: " + strFecha);
                SW.WriteLine("-------------------------------------------------------------------------------- ");

                Class1.strEscrituraLog = "SI";
            }

            SW.WriteLine(strFecha + ",  " + strTextoLog);
            SW.Close();
        }
Example #18
0
        public void saveErrLog(string log, string txtName, string expandedName)
        {
            log = "--" + DateTime.Now.ToString() + " : \n" + log;
            if (Directory.Exists(Application.StartupPath + "\\审计\\") == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(Application.StartupPath + "\\审计\\");
            }
            //if (File.Exists(Application.StartupPath + "\\审计\\" + txtName + ".sql"))
            //{
            //    StreamWriter SW;
            //    SW = File.AppendText(Application.StartupPath + "\\审计\\" + txtName + ".sql");
            //    SW.WriteLine(log + "\r\n");
            //    SW.Close();
            //    //Console.WriteLine("Text Appended Successfully");
            //}
            //else
            //{
            StreamWriter SW;

            SW = File.CreateText(Application.StartupPath + "\\审计\\" + txtName + ".sql");
            SW.WriteLine(log + "\r\n");
            SW.Close();
            listBox1.Items.Add("" + txtName + ".sql已经重新创建!");
            //}
        }
Example #19
0
 public override void ConsumeCCSRead(PacBioCCSRead read, BWAPairwiseAlignment aln, List <Variant> variants)
 {
     if (variants == null)
     {
         return;
     }
     foreach (var v in variants)
     {
         var common = String.Join(",", read.Movie, read.HoleNumber.ToString(), v.RefName,
                                  v.StartPosition.ToString(), v.Length.ToString(), v.Type.ToString(), v.QV.ToString(), v.AtEndOfAlignment.ToString());
         var    snp = v as SNPVariant;
         string unique;
         if (snp != null)
         {
             unique = String.Join(",", snp.RefBP, snp.AltBP, "NA,NA,NA,NA,NA");
         }
         else
         {
             var indel = v as IndelVariant;
             unique = string.Join(",", "NA,NA", indel.InsertionOrDeletion.ToString(),
                                  indel.InHomopolymer.ToString(), indel.InsertedOrDeletedBases.ToString(),
                                  indel.HomopolymerLengthInReference.ToString(), indel.HomopolymerBase);
         }
         SW.WriteLine(common + "," + unique);
     }
 }
        /// <summary>
        /// 1つのフィールドの分析
        /// </summary>
        /// <param name="m">オブジェクト</param>
        /// <param name="nestLevel">整形用</param>
        static void AnalyzeFieldInfo(FieldInfo m, int nestLevel)
        {
            if (!m.IsPublic)
            {
                return;
            }

            var ts = TypeToString(m.FieldType);

            // 複雑過ぎるかどうか
            var  genlist   = m.FieldType.GetGenericArguments();
            bool isComplex = IsGenericAnyCondtion(genlist, (g) => { return(g.ToString().Contains(".")); });

            ts = ModifyType(ts, isComplex);

            SWTabSpace(nestLevel + 1);

            // 読み取り専用
            if (m.IsInitOnly || m.IsLiteral)
            {
                SW.Write("readonly ");
            }

            SW.WriteLine(m.Name + " :" + ts + ";");
        }
Example #21
0
        public static void Write(string s)
        {
            string       sFileName = null;
            StreamWriter SW;

            lock (thisLock)
            {
                sFileName = logPath;
                if (!Directory.Exists(sFileName))
                {
                    Directory.CreateDirectory(sFileName);
                }

                sFileName = logPath + "\\" + DateTime.Today.ToString("yyyyMMdd") + ".log";
                if (!File.Exists(sFileName))
                {
                    SW = File.CreateText(sFileName);
                }
                else
                {
                    SW = File.AppendText(sFileName);
                }
                SW.WriteLine(DateTime.Today.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("hh:mm:ss") + "  " + s);
                SW.Close();
            }
        }
Example #22
0
        private void button1_Click(object sender, EventArgs e)
        {
            FileStream c = File.Create(updateFile);

            c.Close();

            foreach (string f in Directory.GetFiles(Application.StartupPath, "*"))
            {
                try
                {
                    if (f.ToLower() == Application.ExecutablePath.ToLower())
                    {
                        continue;
                    }
                    if (f == updateFile)
                    {
                        continue;
                    }
                    FileStream   file = new FileStream(f, FileMode.Open);
                    StreamWriter SW;
                    SW = File.AppendText(updateFile);
                    SW.WriteLine(f.Replace(Application.StartupPath, "") + "*" + getMd5Hash(file));
                    SW.Close();
                    file.Close();
                }
                catch (System.Exception excpt)
                {
                    Console.WriteLine(excpt.Message);
                }
            }


            DirSearch(Application.StartupPath);
            MessageBox.Show("Done");
        }
Example #23
0
        public static void recordMistake(VocabEntry ve, string status)
        {
            mistakes.Add(new VocabEntry(ve));

            StreamWriter SW;

            SW = File.AppendText(basedir + @"mistakes.txt");
            SW.WriteLine(status + " " + ve.portuguese.PadRight(30) + " " + DateTime.Now);
            SW.Close();

            for (int i = 0; i < 10; i++)
            {
                vocabList.Add(new VocabEntry(ve));
            }

            // re-randomize
            List <VocabEntry> tmpList = vocabList;

            vocabList = new List <VocabEntry>();
            int index;

            while (tmpList.Count > 0)
            {
                index = r.Next(0, tmpList.Count);
                vocabList.Add(tmpList.ElementAt(index));
                tmpList.RemoveAt(index);
            }
            return;
        }
Example #24
0
        private void writeLog(string FullPath, string FileName, string EventType)
        {
            StreamWriter SW;
            string       Logs = ConfigurationManager.AppSettings["Logs"];

            if (Directory.Exists(Logs))
            {
                Logs = System.IO.Path.Combine(Logs, "FaxPDFlog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(Logs))
                {
                    SW = File.CreateText(Logs);
                    SW.Close();
                }
            }
            using (SW = File.AppendText(Logs))
            {
                SW.Write("\r\n");
                if ((EventType == "Created" || EventType == "Changed" || EventType == "Renamed" || EventType == "Converted" || EventType == "Mailed"))
                {
                    SW.WriteLine(DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + ": File " + EventType + " with Name: " + FileName + " at this location: " + FullPath);
                }
                else if ((EventType == "Stopped" || EventType == "Started"))
                {
                    SW.WriteLine("Service " + EventType + " at " + DateTime.Now.ToString("dd -MM-yyyy H:mm:ss"));
                }
                else if (EventType == "Error")
                {
                    SW.WriteLine("ERROR: " + DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + FullPath + FileName);
                }
                SW.Close();
            }
        }
Example #25
0
    private static void SaveConfig(SceneInfo sceneInfo, string path)
    {
        string content = sceneInfo.ToXMLString();
        string name    = Path.GetFileNameWithoutExtension(path);

        path = Application.dataPath + "/ArtAssets/prefabs/configs/map_res/" + name + ".xml";

        if (File.Exists(path))
        {
            File.Delete(path);
        }
        StreamWriter SW;

        SW = File.CreateText(path);
        SW.WriteLine(content);
        SW.Close();

        if (sceneInfo.SaveGridsByBytes)
        {
            //存为byte stream
            path = Application.dataPath + "/ArtAssets/prefabs/configs/map_res/" + name + "_grids" + ".txt";
            FileStream fileStream = File.Create(path);
            fileStream.Write(sceneInfo.GridsBytes, 0, sceneInfo.GridsBytes.Length);
            fileStream.Close();
        }
        else
        {
            // 存为txt
            path = Application.dataPath + "/ArtAssets/prefabs/configs/map_res/" + name + "_grids" + ".txt";
            SW   = File.CreateText(path);
            SW.WriteLine(sceneInfo.GridsContent);
            SW.Close();
        }
    }
Example #26
0
        public static void recordMistake(Verbiage ve, string status)
        {
            mistakes.Add(new Verbiage(ve));

            StreamWriter SW;

            SW = File.AppendText(basedir + @"mistakes.txt");
            SW.WriteLine((status + " " + ve.Infinitive + ", " + ve.Pronoun.ToString() + " " + ve.ConjugatedVerb + ", " + ve.Conjugation.ToString()).PadRight(50) + " " + DateTime.Now);
            SW.Close();

            for (int i = 0; i < 1; i++) // down to 1 from 10 !
            {
                infinitives.Add(ve.Infinitive);
            }

            // re-randomize
            List <string> tmpList = infinitives;

            infinitives = new List <string>();
            int index;

            while (tmpList.Count > 0)
            {
                index = r.Next(0, tmpList.Count);
                infinitives.Add(tmpList.ElementAt(index));
                tmpList.RemoveAt(index);
            }

            return;
        }
Example #27
0
        private void AppendToFile(string sPath, string sText)
        {
            StreamWriter SW;

            SW = File.AppendText(sPath);
            SW.WriteLine(sText);
            SW.Close();
        }
    /// <summary>
    /// 创建文本
    /// </summary>
    /// <param name="vFileName"></param>
    /// <param name="vContent"></param>
    public static void WriteToFile(string vFileName, string vContent)
    {
        StreamWriter SW;

        SW = File.CreateText(vFileName);
        SW.WriteLine(vContent);
        SW.Close();
    }
Example #29
0
        private void SaveLog(String Log)
        {
            StreamWriter SW;

            SW = File.AppendText("Informacje o bocianach - program.txt");
            SW.WriteLine(Log);
            SW.Close();
        }
Example #30
0
        private static void CreateLog(string LogFile)
        {
            StreamWriter SW;

            SW = File.CreateText(LogFile);
            SW.WriteLine("Log created at: " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
            SW.Close();
        }