Save Contents As File - CSharp System.IO

CSharp examples for System.IO:Text File

Description

Save Contents As File

Demo Code


using System.Text;
using System.IO;//from ww  w. j  av  a 2 s.c  om

public class Main{
        public static void SaveContentsAsFile(string content, string path)
        {
            byte[] info = new UTF8Encoding(true).GetBytes(content);
            FileStream fs = File.Create(path);
            fs.Write(info, 0, info.Length);
            fs.Close();
        }
}

Related Tutorials