mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Improve error message if no write access to video source folder
Related to #7696
This commit is contained in:
parent
be8cb936b3
commit
88965b913e
@ -258,9 +258,22 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToString()}.{format.Extension}";
|
||||
}
|
||||
|
||||
File.WriteAllText(fileName, text, Encoding.UTF8);
|
||||
textBoxLog.AppendText("Subtitle written to : " + fileName + Environment.NewLine);
|
||||
_outputBatchFileNames.Add(fileName);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(fileName, text, Encoding.UTF8);
|
||||
textBoxLog.AppendText("Subtitle written to : " + fileName + Environment.NewLine);
|
||||
_outputBatchFileNames.Add(fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
var dir = Path.GetDirectoryName(fileName);
|
||||
if (!WhisperAudioToText.IsDirectoryWritable(dir))
|
||||
{
|
||||
MessageBox.Show($"SE does not have write access to the folder '{dir}'", MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetLanguage(string text)
|
||||
|
@ -677,9 +677,37 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
fileName = $"{Path.Combine(Utilities.GetPathAndFileNameWithoutExtension(videoFileName))}.{Guid.NewGuid().ToString()}.{format.Extension}";
|
||||
}
|
||||
|
||||
File.WriteAllText(fileName, text, Encoding.UTF8);
|
||||
_outputText.Add("Subtitle written to : " + fileName);
|
||||
_outputBatchFileNames.Add(fileName);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(fileName, text, Encoding.UTF8);
|
||||
_outputText.Add("Subtitle written to : " + fileName);
|
||||
_outputBatchFileNames.Add(fileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
var dir = Path.GetDirectoryName(fileName);
|
||||
if (!IsDirectoryWritable(dir))
|
||||
{
|
||||
MessageBox.Show($"SE does not have write access to the folder '{dir}'", MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDirectoryWritable(string dirPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose))
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetLanguage(string name)
|
||||
|
Loading…
Reference in New Issue
Block a user