本文整理汇总了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();
}
示例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);
}
}
示例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();
}
示例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();
}
}
示例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;
}
示例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));
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........
示例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 {
//.........这里部分代码省略.........