Advertisement
tolikpunkoff

RWFile

Feb 18th, 2018
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. public static class RWFile
  2.     {
  3.         public static int CP = 28605;
  4.  
  5.         public static string ReadFile(string FileName)
  6.         {          
  7.             byte[] TempBuf = File.ReadAllBytes(FileName);
  8.            
  9.             string ReadBuf = "";
  10.             StreamReader sr = new StreamReader(FileName, Encoding.GetEncoding(CP), false);
  11.             ReadBuf=sr.ReadToEnd();
  12.             sr.Close();
  13.             return ReadBuf;
  14.         }
  15.  
  16.         public static void WriteFile(string FileName, string FileData, bool Backup)
  17.         {
  18.             if (Backup)
  19.             {
  20.                 File.Copy(FileName, FileName + ".bak", true);
  21.             }
  22.             StreamWriter sw = new StreamWriter(FileName, false, Encoding.GetEncoding(CP));
  23.             sw.Write(FileData);
  24.             sw.Close();
  25.                        
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement