public string GetFileContent(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentException(
string.Format(CommonStrings.ErrorMessage_FilePathNotSpecified, filePath),
"filePath"
);
}
string content;
string fullFilePath = _textContentDirectoryPath.TrimEnd('/') + "/" + filePath;
string physicalFilePath = GetPhysicalFilePath(fullFilePath);
try
{
using (FileStream fileStream = File.OpenRead(physicalFilePath))
using (var reader = new StreamReader(fileStream))
{
content = reader.ReadToEnd();
}
}
catch (FileNotFoundException)
{
throw new FileNotFoundException(
string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
}
catch (DirectoryNotFoundException)
{
throw new FileNotFoundException(
string.Format(CommonStrings.ErrorMessage_FileNotFound, filePath));
}
return content;
}