From 4095b6b82c2893e9669df8c3e75f0f6aa3836eec Mon Sep 17 00:00:00 2001 From: Nvmkpk Date: Tue, 28 Jun 2016 20:41:51 -0400 Subject: [PATCH] Update EditProjPackage.cs Work with bytes so as to not modify the current encoding of the file. --- EditProj/EditProjPackage.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EditProj/EditProjPackage.cs b/EditProj/EditProjPackage.cs index 609d1c6..72c3ccc 100644 --- a/EditProj/EditProjPackage.cs +++ b/EditProj/EditProjPackage.cs @@ -134,8 +134,8 @@ private static string GetNewTempFilePath() private static void CreateTempFileWithContentsOf(string sourcePath, string destPath) { - string projectData = File.ReadAllText(sourcePath); - File.WriteAllText(destPath, projectData); + byte[] projectData = File.ReadAllBytes(sourcePath); + File.WriteAllBytes(destPath, projectData); } private bool TempFileExists(string projFilePath, out string tempProjFile) @@ -199,7 +199,7 @@ private void exitCommand_BeforeExecute(string Guid, int ID, object CustomIn, obj private void UpdateProjFile(string tempFilePath) { - string contents = ReadFile(tempFilePath); + byte[] contents = ReadFile(tempFilePath); string projFile = this.tempToProjFiles[tempFilePath]; if (CanEditFile(this.tempToProjFiles[tempFilePath])) { @@ -217,14 +217,14 @@ private void NotifyForSave(string filePath) hr = queryEditQuerySave.QuerySaveFile(filePath, 0, null, out result); } - private static void SetFileContents(string filePath, string content) + private static void SetFileContents(string filePath, byte[] content) { - File.WriteAllText(filePath, content); + File.WriteAllBytes(filePath, content); } - private static string ReadFile(string filePath) + private static byte[] ReadFile(string filePath) { - return File.ReadAllText(filePath); + return File.ReadAllBytes(filePath); } private bool CanEditFile(string filePath)