mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Allow import plain text even if file is in use - thx darnn :)
Fix #2642
This commit is contained in:
parent
5b97f42f51
commit
ca6d9d54fd
@ -39,6 +39,16 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] ReadAllLinesShared(string path, Encoding encoding)
|
||||
{
|
||||
return encoding.GetString(ReadAllBytesShared(path)).SplitToLines();
|
||||
}
|
||||
|
||||
public static string ReadAllTextShared(string path, Encoding encoding)
|
||||
{
|
||||
return encoding.GetString(ReadAllBytesShared(path));
|
||||
}
|
||||
|
||||
public static bool IsZip(string fileName)
|
||||
{
|
||||
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
@ -150,7 +150,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ext = extension.ToLowerInvariant();
|
||||
|
||||
var fd = new FinalDraftTemplate2();
|
||||
var list = new List<string>(File.ReadAllLines(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)));
|
||||
var list = new List<string>(FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName)));
|
||||
bool isFinalDraft = fd.IsMine(list, fileName);
|
||||
|
||||
if (ext == ".astx")
|
||||
@ -694,7 +694,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
try
|
||||
{
|
||||
Encoding encoding = LanguageAutoDetect.GetEncodingFromFile(fileName);
|
||||
var text = File.ReadAllText(fileName, encoding);
|
||||
var text = FileUtil.ReadAllTextShared(fileName, encoding);
|
||||
if (fileName.EndsWith(".htm", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".htm", StringComparison.OrdinalIgnoreCase))
|
||||
text = HtmlToPlainText(text);
|
||||
return text;
|
||||
|
Loading…
Reference in New Issue
Block a user