Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
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 { }
        }
Esempio n. 3
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 { }
        }
Esempio n. 4
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 { }
        }
Esempio n. 5
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();
    }
Esempio n. 6
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;
        }
Esempio n. 7
0
        public static int TabToFile(string filename, int[,] tab)
        {
            StreamWriter SW;
            string       line = "";

            try {
                SW = new StreamWriter(new FileStream(filename, FileMode.CreateNew));
            } catch (Exception) {
                Console.WriteLine("ERROR : File already exists !");
                do
                {
                    Console.WriteLine("Do you want to overrite it ? (y/n) : ");
                    line = Console.ReadLine();
                } while (line != "y" && line != "Y" && line != "n" && line != "N");
                if (line == "n" || line == "N")
                {
                    return(1);
                }
                else
                {
                    SW = new StreamWriter(new FileStream(filename, FileMode.Create));
                }
            }
            for (int i = 0; i < tab.GetLength(0); ++i)
            {
                for (int j = 0; j < tab.GetLength(1); ++j)
                {
                    SW.Write(tab [i, j]);
                }
                SW.Write("\n");
            }
            SW.Close();
            return(0);
        }
Esempio n. 8
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);
        }
            /// <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);
                    }
                }
            }
Esempio n. 10
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);
                }
            }
        }
Esempio n. 11
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);
         }
     }
 }
Esempio n. 12
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();
            }
        }
    /// <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);;
            }
        }
    }
Esempio n. 14
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已经重新创建!");
            //}
        }
Esempio n. 15
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();
            }
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            Console.WriteLine("Exemplo de Assinatura Digital XML\r\r");
            Console.Write("Arquivo xml a ser assinado :");
            string _arquivo = Console.ReadLine();

            if (_arquivo == null)
            {
                Console.WriteLine("\rNome de arquivo não informado...");
            }
            else if (!File.Exists(_arquivo))
            {
                Console.WriteLine("\rArquivo {0} inexistente...", _arquivo);
            }
            else
            {
                Console.Write("URI a ser assinada (Ex.: infCanc, infNFe, infInut, etc.) :");
                string _uri = Console.ReadLine();
                if (_uri == null)
                {
                    Console.WriteLine("\rURI não informada...");
                }
                else
                {
                    //
                    //   le o arquivo xml
                    //
                    StreamReader SR;
                    string       _stringXml;
                    SR         = File.OpenText(_arquivo);
                    _stringXml = SR.ReadToEnd();
                    SR.Close();
                    //
                    //  realiza assinatura
                    //
                    AssinaturaDigital AD = new AssinaturaDigital();
                    //
                    //  cria cert
                    //
                    X509Certificate2 cert = new X509Certificate2();
                    //
                    //  seleciona certificado do repositório MY do windows
                    //
                    Certificado certificado = new Certificado();
                    cert = certificado.BuscaNome("");
                    int resultado = AD.Assinar(_stringXml, _uri, cert);
                    if (resultado == 0)
                    {
                        //
                        //  grava arquivo assinado
                        //
                        StreamWriter SW;
                        SW = File.CreateText(_arquivo.Trim() + "_assinado");
                        SW.Write(AD.XMLStringAssinado);
                        SW.Close();
                    }
                    Console.WriteLine(AD.mensagemResultado);
                }
            }
        }
Esempio n. 17
0
        private string saveScript(string filename, string contents)
        {
            string val         = contents;
            string returnValue = "false";

            try
            {
                string savePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename);

                //Directory check.. only allow files in script dir and below to be edited
                if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Scripts + "/")))
                {
                    StreamWriter SW;
                    SW = File.CreateText(IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename));
                    SW.Write(val);
                    SW.Close();
                    returnValue = "true";
                }
                else
                {
                    throw new ArgumentException("Couldnt save to file - Illegal path");
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(String.Format("Couldnt save to file '{0}'", filename), ex);
            }


            return(returnValue);
        }
Esempio n. 18
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();
        }
Esempio n. 19
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();
            }
        }
Esempio n. 20
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");
        }
Esempio n. 21
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;
        }
Esempio n. 22
0
        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();
        }
Esempio n. 23
0
        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();
        }
Esempio n. 24
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();
        }
    }
Esempio n. 25
0
        //private void BT_UpLoadData_Click(object sender, RoutedEventArgs e)
        //{
        //   // queryThread.Suspend(); //暂时关闭查询用线程
        //    mdv.pmacCard.SendCMD("LIST GAT");
        //    mdv.PMAC_msg = mdv.pmacCard.m_PMAC_msg;
        //    System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
        //    sfd.InitialDirectory = "E:\\";
        //    sfd.Filter = "m文件(*.m)|*.m|txt文件(*.txt)|*.txt";
        //    if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        //    {
        //        WriteToFile(sfd.FileName, "OriData = {'" + mdv.PMAC_msg.Replace(" ","' , '").Replace("\n", "' ,...\n '") + "'};");
        //        MessageBox.Show("uploaded complete");
        //    }
        //    //queryThread.Resume();
        //}

        #endregion

        static void WriteToFile(string dir, string data)
        {
            StreamWriter SW;

            SW = File.CreateText(dir);
            SW.Write(data);
            SW.Close();
        }
Esempio n. 26
0
    /// <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();
    }
Esempio n. 27
0
        private void SaveLog(String Log)
        {
            StreamWriter SW;

            SW = File.AppendText("Informacje o bocianach - program.txt");
            SW.WriteLine(Log);
            SW.Close();
        }
Esempio n. 28
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();
        }
Esempio n. 29
0
        private void AppendToFile(string sPath, string sText)
        {
            StreamWriter SW;

            SW = File.AppendText(sPath);
            SW.WriteLine(sText);
            SW.Close();
        }
Esempio n. 30
0
        // Write a string to a file
        public static void WriteToFile(string tempFilePath, string stringToWrite)
        {
            StreamWriter SW;

            SW = File.CreateText(tempFilePath);
            SW.Write(stringToWrite);
            SW.Close();
        }