From 9f748bf2bf2e386f46a20c69544bb090e435bf38 Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Thu, 25 Nov 2021 17:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20hosts=20=E5=8F=AA=E8=AF=BB?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=93=8D=E4=BD=9C=EF=BC=8C=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=20windows=20=E4=B8=8A=20hosts=20=E6=96=87=E4=BB=B6=E5=8F=AA?= =?UTF-8?q?=E8=AF=BB=E6=97=A0=E6=B3=95=E4=BF=AE=E6=94=B9=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implementation/HostsFileServiceImpl.cs | 10 ++-------- src/ST.Client/UI/Resx/AppResources.Designer.cs | 2 +- src/ST.Client/UI/Resx/AppResources.en.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.es.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.it.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.ja.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.ko.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.resx | 2 +- src/ST.Client/UI/Resx/AppResources.ru.resx | 4 ---- src/ST.Client/UI/Resx/AppResources.zh-Hant.resx | 4 ---- 10 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/ST.Client/Services/Implementation/HostsFileServiceImpl.cs b/src/ST.Client/Services/Implementation/HostsFileServiceImpl.cs index 3b61eb467..4ef72e0d8 100644 --- a/src/ST.Client/Services/Implementation/HostsFileServiceImpl.cs +++ b/src/ST.Client/Services/Implementation/HostsFileServiceImpl.cs @@ -107,11 +107,6 @@ namespace System.Application.Services.Implementation return false; } } - if (fileInfo.IsReadOnly) - { - message = AppResources.FileAttributeIsReadOnlyModifyFail; - return false; - } //if (fileInfo.IsReadOnly&&(OperatingSystem2.IsMacOS || (OperatingSystem2.IsLinux && !s.IsAdministrator))) //{ // var editPath = Path.Combine(IOPath.CacheDirectory, "hosts"); @@ -132,12 +127,11 @@ namespace System.Application.Services.Implementation } if (checkReadOnly) { - var attr = fileInfo.Attributes; - if (attr.HasFlag(FileAttributes.ReadOnly)) + if (fileInfo.IsReadOnly) { try { - fileInfo.Attributes = attr & ~FileAttributes.ReadOnly; + fileInfo.IsReadOnly = false; } catch (Exception) { diff --git a/src/ST.Client/UI/Resx/AppResources.Designer.cs b/src/ST.Client/UI/Resx/AppResources.Designer.cs index d2dc99981..1eb0e9b22 100644 --- a/src/ST.Client/UI/Resx/AppResources.Designer.cs +++ b/src/ST.Client/UI/Resx/AppResources.Designer.cs @@ -1536,7 +1536,7 @@ namespace System.Application.UI.Resx { } /// - /// 查找类似 文件属性为只读,修改失败 的本地化字符串。 + /// 查找类似 文件属性为只读,修改失败,你可以尝试先备份该文件后删除再重试一遍 的本地化字符串。 /// public static string FileAttributeIsReadOnlyModifyFail { get { diff --git a/src/ST.Client/UI/Resx/AppResources.en.resx b/src/ST.Client/UI/Resx/AppResources.en.resx index ef5041bda..c38ea0ad3 100644 --- a/src/ST.Client/UI/Resx/AppResources.en.resx +++ b/src/ST.Client/UI/Resx/AppResources.en.resx @@ -2173,10 +2173,6 @@ Announcement notification Comment=;Author=MicrosoftTranslator - - The file property is read-only and the modification fails - Comment=;Author=MicrosoftTranslator - The file size is too large Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.es.resx b/src/ST.Client/UI/Resx/AppResources.es.resx index 0038a7020..d4557c318 100644 --- a/src/ST.Client/UI/Resx/AppResources.es.resx +++ b/src/ST.Client/UI/Resx/AppResources.es.resx @@ -2173,10 +2173,6 @@ Notificación de anuncio Comment=;Author=MicrosoftTranslator - - La propiedad file es de sólo lectura y se produce un error en la modificación - Comment=;Author=MicrosoftTranslator - El tamaño del archivo es demasiado grande Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.it.resx b/src/ST.Client/UI/Resx/AppResources.it.resx index 8b084a353..05746781e 100644 --- a/src/ST.Client/UI/Resx/AppResources.it.resx +++ b/src/ST.Client/UI/Resx/AppResources.it.resx @@ -2173,10 +2173,6 @@ Notifica annuncio Comment=;Author=MicrosoftTranslator - - La proprietà del file è di sola lettura e la modifica non riesce - Comment=;Author=MicrosoftTranslator - Le dimensioni del file sono troppo grandi Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.ja.resx b/src/ST.Client/UI/Resx/AppResources.ja.resx index 595cf523a..062ff9832 100644 --- a/src/ST.Client/UI/Resx/AppResources.ja.resx +++ b/src/ST.Client/UI/Resx/AppResources.ja.resx @@ -2169,10 +2169,6 @@ お知らせのお知らせ Comment=;Author=MicrosoftTranslator - - ファイルの属性が読み取り専用のため、修正に失敗 - Comment=;Author=MicrosoftTranslator - ファイルサイズが大きすぎる Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.ko.resx b/src/ST.Client/UI/Resx/AppResources.ko.resx index 338135dda..c47738377 100644 --- a/src/ST.Client/UI/Resx/AppResources.ko.resx +++ b/src/ST.Client/UI/Resx/AppResources.ko.resx @@ -2169,10 +2169,6 @@ 공지 사항 Comment=;Author=MicrosoftTranslator - - 파일 속성이 읽기 전용이며 수정에 실패했습니다 - Comment=;Author=MicrosoftTranslator - 파일 크기가 너무 큽니다 Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.resx b/src/ST.Client/UI/Resx/AppResources.resx index 00b3b5824..b5d6acea0 100644 --- a/src/ST.Client/UI/Resx/AppResources.resx +++ b/src/ST.Client/UI/Resx/AppResources.resx @@ -1797,7 +1797,7 @@ AAAAA-BBBBB-CCCC3 下载更新包失败,请稍后重试 - 文件属性为只读,修改失败 + 文件属性为只读,修改失败,你可以尝试先备份该文件后删除再重试一遍 文件大小过大 diff --git a/src/ST.Client/UI/Resx/AppResources.ru.resx b/src/ST.Client/UI/Resx/AppResources.ru.resx index 27f0df4f4..4c1d01d1f 100644 --- a/src/ST.Client/UI/Resx/AppResources.ru.resx +++ b/src/ST.Client/UI/Resx/AppResources.ru.resx @@ -2169,10 +2169,6 @@ Уведомление о объявлении Comment=;Author=MicrosoftTranslator - - Свойства файла доступен только для чтения, и изменение завершается неудачей - Comment=;Author=MicrosoftTranslator - Размер файла слишком большой Comment=;Author=MicrosoftTranslator diff --git a/src/ST.Client/UI/Resx/AppResources.zh-Hant.resx b/src/ST.Client/UI/Resx/AppResources.zh-Hant.resx index 26068a2e9..e7acd61eb 100644 --- a/src/ST.Client/UI/Resx/AppResources.zh-Hant.resx +++ b/src/ST.Client/UI/Resx/AppResources.zh-Hant.resx @@ -2169,10 +2169,6 @@ 公告通知 Comment=;Author=MicrosoftTranslator - - 文件屬性為只讀,修改失敗 - Comment=;Author=MicrosoftTranslator - 文件大小過大 Comment=;Author=MicrosoftTranslator