Esempio n. 1
0
 /// <summary>
 /// Writes a text file to the specified location (if Unicode, with or without BOM)
 /// </summary>
 public static void WriteFile(String file, String text, Encoding encoding, Boolean saveBOM)
 {
     Boolean useSkipBomWriter = (encoding == Encoding.UTF8 && !saveBOM);
     if (encoding == Encoding.UTF7) encoding = new UTF7EncodingFixed();
     using (StreamWriter sw = useSkipBomWriter ? new StreamWriter(file, false) : new StreamWriter(file, false, encoding))
     {
         sw.Write(text);
         sw.Close();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Writes a text file to the specified location (if Unicode, with or without BOM)
        /// </summary>
        public static void WriteFile(String file, String text, Encoding encoding, Boolean saveBOM)
        {
            Boolean useSkipBomWriter = (encoding == Encoding.UTF8 && !saveBOM);

            if (encoding == Encoding.UTF7)
            {
                encoding = new UTF7EncodingFixed();
            }
            using (StreamWriter sw = useSkipBomWriter ? new StreamWriter(file, false) : new StreamWriter(file, false, encoding))
            {
                sw.Write(text);
                sw.Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Writes a text file to the specified location (if Unicode, with or without BOM)
        /// </summary>
        public static void WriteFile(String file, String text, Encoding encoding, Boolean saveBOM)
        {
            Boolean useSkipBomWriter = (encoding == Encoding.UTF8 && !saveBOM);

            if (encoding == Encoding.UTF7)
            {
                encoding = new UTF7EncodingFixed();
            }
            using (FileStream fs = new FileStream(file, File.Exists(file) ? FileMode.Truncate : FileMode.CreateNew))
                using (StreamWriter sw = useSkipBomWriter ? new StreamWriter(fs) : new StreamWriter(fs, encoding))
                {
                    sw.Write(text);
                    sw.Close();
                }
        }
Esempio n. 4
0
 /// <summary>
 /// Writes a text file to the specified location (if Unicode, with or without BOM)
 /// </summary>
 public static void WriteFile(String file, String text, Encoding encoding, Boolean saveBOM)
 {
     Boolean useSkipBomWriter = (encoding == Encoding.UTF8 && !saveBOM);
     if (encoding == Encoding.UTF7) encoding = new UTF7EncodingFixed();
     using (FileStream fs = new FileStream(file, File.Exists(file) ? FileMode.Truncate : FileMode.CreateNew))
     using (StreamWriter sw = useSkipBomWriter ? new StreamWriter(fs) : new StreamWriter(fs, encoding))
     {
         sw.Write(text);
         sw.Close();
     }
 }