当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.FileInfo.AppendText方法代码示例

本文整理汇总了C#中System.IO.FileInfo.AppendText方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.AppendText方法的具体用法?C# System.IO.FileInfo.AppendText怎么用?C# System.IO.FileInfo.AppendText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了System.IO.FileInfo.AppendText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button4_Click_2

 private void button4_Click_2(object sender, EventArgs e)
 {
     System.IO.StreamWriter sw;
     System.IO.FileInfo fi = new System.IO.FileInfo("namef.txt");
     sw = fi.AppendText();
     sw.WriteLine(textBox1.Text);
     sw.Close();
 }
开发者ID:jordanLex,项目名称:DarkSiders,代码行数:8,代码来源:Form1.cs

示例2: textBox1_KeyDown

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.ToString() == "return");
            if (e.KeyCode==Keys.Enter)
            {
                System.IO.StreamWriter sw;
                System.IO.FileInfo fi = new System.IO.FileInfo("name.txt");
                sw = fi.AppendText();
                sw.WriteLine(textBox1.Text);
                sw.Close();
                tabs.SelectedTab.Text = textBox1.Text;
                ((WebBrowser)tabs.SelectedTab.Controls[0]).Navigate(@"http://www." + textBox1.Text);

            }
        }
开发者ID:jordanLex,项目名称:new1,代码行数:15,代码来源:Form1.cs

示例3: addLog

        public static void addLog(string logText)
        {
            DateTime time = DateTime.Now;
            string sec = time.Second.ToString();
            string min = time.Minute.ToString();
            string hour = time.Hour.ToString();
            string day = time.Day.ToString();
            string month = time.Month.ToString();
            string year = time.Year.ToString();

            if (int.Parse(sec) < 10)
            {
                sec = "0" + sec;
            }

            if (int.Parse(min) < 10)
            {
                min = "0" + min;
            }

            if (int.Parse(hour) < 10)
            {
                hour = "0" + hour;
            }
            if (!System.IO.Directory.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\EvEMU DB\\"))
            {
                System.IO.Directory.CreateDirectory(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\EvEMU DB\\");
            }
            // Just a test, even though i think CreateDirectory checks if the directory is there anyways...
            //System.IO.Directory.CreateDirectory(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\EvEMU DB\\");

            System.IO.FileInfo fi = new System.IO.FileInfo(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\EvEMU DB\\log.log");
            System.IO.StreamWriter appendLog = fi.AppendText();
            string logInfo = "[Log][" + day + "/" + month + "/" + year + " :: " + hour + ":" + min + ":" + sec + "]: \"" + logText + "\"\n";
            appendLog.WriteLine(logInfo);
            appendLog.Close();
        }
开发者ID:positron96,项目名称:evemu_control_panel,代码行数:37,代码来源:LogSystem.cs

示例4: writeFile

        public static void writeFile(String logMessage)
        {

            System.IO.FileStream fileStream = null;
            System.IO.StreamWriter sr = null;
            try
            {
                DateTime dt = DateTime.Now;
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(_logFile);
                if (!fileInfo.Exists)
                {
                    fileStream = fileInfo.Open(System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                    sr = new System.IO.StreamWriter(fileStream);
                }
                else
                {
                    sr = fileInfo.AppendText();
                }


                sr.Write(logMessage);

            }
            catch (Exception ex)
            {

            }
            finally
            {
                if (sr != null)
                    sr.Close();
                if (fileStream != null)
                    fileStream.Close();

            }
        }
开发者ID:Geoneer,项目名称:pdok-extensie,代码行数:36,代码来源:Utils.cs

示例5: OpenFile

        public virtual bool OpenFile()
        {
            try
            {
                if (textWriter != null)
                    CloseFile();

                bool found = false;
                System.IO.FileInfo fileInfo;

                if (Directory != null && Directory != "")
                    CheckDirectoryExists();

                int version = 0;
                do
                {
                    TextFileName = GetCandidateName(version++);
                    fileInfo = new System.IO.FileInfo(TextFileName);

                    if (autoNumberVersion)
                        found = !fileInfo.Exists; // find a version that does not exist
                    else
                        found = true; // does not matter if it exists
                }
                while (!found);

                TextFileFullName = fileInfo.Name;
                if (fileInfo.Exists)
                {
                    textWriter = fileInfo.AppendText();
                    isNewFile = false;
                }
                else
                {
                    textWriter = fileInfo.CreateText();
                    isNewFile = true;
                }
            }
            catch (Exception e)
            {
                lastError = e.Message;
                return false;
            }

            lastError = "";
            return true;
        }
开发者ID:alberthoekstra,项目名称:PVBeanCounter,代码行数:47,代码来源:TextFileWriter.cs

示例6: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            string machineName = String.Empty;
            string longKeyName = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";
            string longValName = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345";

            Exception exc = null;
            System.DateTime now = InicDateTime ();
            Object obj = null;
            string[] sL = null;
            Microsoft.Win32.RegistryKey rKey1 = null;
            Microsoft.Win32.RegistryKey rKey = null;
            Microsoft.Win32.RegistryKey rKey2 = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources12reg.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources12reg.txt");

            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey (longKeyName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longKeyName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.CreateSubKey(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey (longKeyName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longKeyName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.DeleteSubKey(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + "");
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.SetValue (longValName, "newData");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.SetValue(String, Object)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + "");
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                obj = null;
                now = System.DateTime.Now;
                /*<Resource>*/obj = Microsoft.Win32.Registry.ClassesRoot.GetValue (longValName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.GetValue(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (obj));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                now = System.DateTime.Now;
                /*<Resource>*/Microsoft.Win32.Registry.ClassesRoot.DeleteValue (longValName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + "HKEY_CLASSES_ROOT\\" + longValName);
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.DeleteValue(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication12.cs

示例7: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            string machineName = String.Empty;

            Exception exc = null;
            System.DateTime now = InicDateTime ();
            Object obj = null;
            string[] sL = null;
            Microsoft.Win32.RegistryKey rKey1 = null;
            Microsoft.Win32.RegistryKey rKey = null;
            Microsoft.Win32.RegistryKey rKey2 = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources2reg.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources2reg.txt");

            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.ClassesRoot, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_CLASSES_ROOT");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.CurrentConfig, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_CURRENT_CONFIG");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.DynData, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_DYN_DATA");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.LocalMachine, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_LOCAL_MACHINE");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (rKey));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                rKey = null;
                now = System.DateTime.Now;
                /*<Resource>*/rKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey (Microsoft.Win32.RegistryHive.PerformanceData, machineName);
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + Extend (machineName) + "HKEY_PERFORMACE_DATA");
                outFile.WriteLine ("Func: " + "Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive, String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication2.cs

示例8: Main

        static void Main(string[] args)
        {
            string tempPath = System.Environment.GetEnvironmentVariable ("TEMP");
            if (tempPath == null) {
                tempPath = System.Environment.GetEnvironmentVariable ("TMP");
            }
            if (tempPath == null) {
                tempPath = "..\\..";
            }

            Exception exc = null;
            System.DateTime now = System.DateTime.Now;
            System.Security.Cryptography.X509Certificates.X509Certificate xc = null;
            System.IO.StreamWriter sw = null;
            System.IO.StreamReader sr = null;
            System.IO.DirectoryInfo di = null;
            bool b = false;
            System.DateTime dt = InicDateTime ();
            string[] sL = null;
            System.IO.FileInfo[] fiL = null;
            System.IO.DirectoryInfo[] diL = null;
            System.IO.FileSystemInfo[] fsiL = null;
            System.IO.FileStream fs = null;
            System.IO.FileInfo fi = null;
            System.IAsyncResult asr = null;
            int i = 0;
            long l = 0;
            string s = null;
            System.IO.IsolatedStorage.IsolatedStorageFile isf = null;
            System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = null;
            byte[] bL = null;
            System.Diagnostics.Process p = null;

            System.IO.FileInfo fileInfo = new System.IO.FileInfo (tempPath + "\\resources4file.txt");
            fileInfo.Create ().Close ();
            System.IO.StreamWriter outFile = fileInfo.AppendText ();
            System.Console.WriteLine (tempPath + "\\resources4file.txt");

            try {
                exc = null;
                xc = null;
                now = System.DateTime.Now;
                xc = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile (tempPath + "\\dummyFile1.txt");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + tempPath + "\\dummyFile1.txt");
                outFile.WriteLine ("Func: " + "System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (xc));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            try {
                exc = null;
                xc = null;
                now = System.DateTime.Now;
                xc = System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile (tempPath + "\\dummyFile2.txt");
            } catch (Exception e) {
                exc = e;
            } finally {
                outFile.WriteLine ("Name: " + tempPath + "\\dummyFile2.txt");
                outFile.WriteLine ("Func: " + "System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromSignedFile(String)");
                outFile.WriteLine ("Proc: " + System.Diagnostics.Process.GetCurrentProcess ().Id);
                outFile.WriteLine ("Time: " + GetTime (now));
                outFile.WriteLine ("Retv: " + toString (xc));
                outFile.WriteLine ("Errc: " + "");
                outFile.WriteLine ("Exce: " + GetException (exc));
            }
            /*
            try {
            System.IO.BinaryWriter.Write ();
            System.IO.BinaryWriter.Seek ();
            System.IO.BinaryWriter.Flush ();
            System.IO.BinaryWriter.Close ();
            System.IO.BinaryWriter bw = new System.IO.BinaryWriter ();
            } catch (Exception e) {
            }

            try {
            System.IO.BufferedStream.WriteByte ();
            System.IO.BufferedStream.Write ();
            System.IO.BufferedStream.ReadByte ();
            System.IO.BufferedStream.Read ();
            System.IO.BufferedStream.SetLength ();
            System.IO.BufferedStream.Seek ();
            System.IO.BufferedStream.EndWrite ();
            System.IO.BufferedStream.BeginWrite ();
            System.IO.BufferedStream.EndRead ();
            System.IO.BufferedStream.BeginRead ();
            System.IO.BufferedStream.Flush ();
            System.IO.BufferedStream.Close ();
            System.IO.BufferedStream bs = new System.IO.BufferedStream ();
            } catch (Exception e) {
            }
            */
            try {
                exc = null;
                try {
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:Holodeck,代码行数:101,代码来源:TestApplication4.cs


注:本文中的System.IO.FileInfo.AppendText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。