public static void WriteUserFile(User tempUser) //Writes one user to the correct file { String fileName = String.Format("{0}{1}", tempUser.GetLoginName, Constants.DotTXT); String userPath = System.IO.Path.Combine(Constants.LoginsPath, fileName); String userContent = tempUser.ToFile(); if (!Directory.Exists(Constants.LoginsPath)) { Directory.CreateDirectory(Constants.LoginsPath); } if (File.Exists(userPath)) { File.Delete(userPath); } using (StreamWriter tempWriter = File.CreateText(userPath)) { String cryptedData = Cryptography.AsymmetricEncrypt(userContent, Constants.AsymmetricPublicKey); tempWriter.WriteLine(cryptedData); } }