9Mcode comment |
 |
 |
|
|
|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #2427 [อื่นๆ] (จาก IP: 222.123.176.164)
C# ทำ ปุ่ม save เขียนยังไงค่ะ
ตอบทีค่ะ
ถ้าต้องการสร้างปุ่ม save โดยสามารถsaveทับไฟล์เดิม โค้ดเขียนยังไงค่ะ
ไม่ใช่save as น่ะค่ะ แค่ save เฉยๆ โดย สามารถแทรกText ในrichTextBoxที่ถูกเพิ่มได้ค่ะช่วย
|
จากคุณ
:
Numay [2009-01-12 04:33:16]
|
|
ความคิดเห็น #27276 (จาก IP: 58.8.186.188)
using System; using System.IO; class DirAppend { public static void Main(String[] args) { using (StreamWriter w = File.AppendText(\"log.txt\")) { Log (\"Test1\", w); Log (\"Test2\", w); // Close the writer and underlying file. w.Close(); } // Open and read the file. using (StreamReader r = File.OpenText(\"log.txt\")) { DumpLog (r); } } public static void Log (String logMessage, TextWriter w) { w.Write(\"\\r\\nLog Entry : \"); w.WriteLine(\"{0} {1}\", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString()); w.WriteLine(\" :\"); w.WriteLine(\" :{0}\", logMessage); w.WriteLine (\"-------------------------------\"); // Update the underlying file. w.Flush(); } public static void DumpLog (StreamReader r) { // While not at the end of the file, read and write lines. String line; while ((line=r.ReadLine())!=null) { Console.WriteLine(line); } r.Close(); } } |
จากคุณ
:
sup98 [2009-01-13 01:16:47]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|
|
|