修复 hosts 只读判断操作,改进 windows 上 hosts 文件只读无法修改时提示语

This commit is contained in:
Aigio Liu
2021-11-25 17:36:33 +08:00
parent bf2d7feaf7
commit 9f748bf2bf
10 changed files with 4 additions and 38 deletions
@@ -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)
{
+1 -1
View File
@@ -1536,7 +1536,7 @@ namespace System.Application.UI.Resx {
}
/// <summary>
/// 查找类似 文件属性为只读,修改失败 的本地化字符串。
/// 查找类似 文件属性为只读,修改失败,你可以尝试先备份该文件后删除再重试一遍 的本地化字符串。
/// </summary>
public static string FileAttributeIsReadOnlyModifyFail {
get {
@@ -2173,10 +2173,6 @@
<value>Announcement notification</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>The file property is read-only and the modification fails</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>The file size is too large</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
@@ -2173,10 +2173,6 @@
<value>Notificación de anuncio</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>La propiedad file es de sólo lectura y se produce un error en la modificación</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>El tamaño del archivo es demasiado grande</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
@@ -2173,10 +2173,6 @@
<value>Notifica annuncio</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>La proprietà del file è di sola lettura e la modifica non riesce</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>Le dimensioni del file sono troppo grandi</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
@@ -2169,10 +2169,6 @@
<value>お知らせのお知らせ</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>ファイルの属性が読み取り専用のため、修正に失敗</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>ファイルサイズが大きすぎる</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
@@ -2169,10 +2169,6 @@
<value>공지 사항</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>파일 속성이 읽기 전용이며 수정에 실패했습니다</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>파일 크기가 너무 큽니다</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
+1 -1
View File
@@ -1797,7 +1797,7 @@ AAAAA-BBBBB-CCCC3</value>
<value>下载更新包失败,请稍后重试</value>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>文件属性为只读,修改失败</value>
<value>文件属性为只读,修改失败,你可以尝试先备份该文件后删除再重试一遍</value>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>文件大小过大</value>
@@ -2169,10 +2169,6 @@
<value>Уведомление о объявлении</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>Свойства файла доступен только для чтения, и изменение завершается неудачей</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>Размер файла слишком большой</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
@@ -2169,10 +2169,6 @@
<value>公告通知</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileAttributeIsReadOnlyModifyFail" xml:space="preserve">
<value>文件屬性為只讀,修改失敗</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>
</data>
<data name="FileSizeTooLarge" xml:space="preserve">
<value>文件大小過大</value>
<comment>Comment=;Author=MicrosoftTranslator</comment>