2013-07-19 18 views

回答

1

這個你怎麼看文件,並檢查

using (StreamReader sr = new StreamReader(path)); 
{ 
    string contents = sr.ReadToEnd(); 

    if (contents.Contains(//string to check//)) 
    { 
     appendtofile("add string") 
    } 
} 

,這裏是你如何追加

public void appendtofile(string text) 
{ 


    using (StreamWriter sw = File.AppendText(path)) 
     { 
      sw.WriteLine(text); 

     } 

} 
+0

非常感謝你 – user2510640

相關問題