Catch exceptions when writing files in ImageFileCache

This commit is contained in:
ClemensF 2012-09-26 17:44:58 +02:00
parent d055d737ed
commit 5760471c1c

View file

@ -171,11 +171,19 @@ namespace Caching
if (extension != null)
{
var path = GetPath(key) + extension;
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (FileStream fileStream = new FileStream(path, FileMode.Create))
try
{
fileStream.Write(buffer, 8, buffer.Length - 8);
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (FileStream fileStream = new FileStream(path, FileMode.Create))
{
fileStream.Write(buffer, 8, buffer.Length - 8);
}
}
catch (Exception ex)
{
Trace.TraceWarning("ImageFileCache: Writing file {0} failed: {1}", path, ex.Message);
}
}
}