随笔 - 35  文章 - 0  评论 - 609  阅读 - 20万

Save or append text to a file (c#)

偶然看到rippleyong [涟漪勇]Post了一个VB.NET版的Save or append text to a file,于是一阵手痒,便有了这C#版的Method:
public static bool SaveTextToFile(string filepath,string text,bool append)
    
{    
        
using(System.IO.StreamWriter sw=new System.IO.StreamWriter(filepath,append))
        
{
            
try
            
{        
                sw.Write(text);
                
return true;
            }

            
catch
            
{
                
return false;
            }

        }
        
    }
posted on   恩电  阅读(1563)  评论(0编辑  收藏  举报
(评论功能已被禁用)

点击右上角即可分享
微信分享提示