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,6 +171,9 @@ namespace Caching
if (extension != null)
{
var path = GetPath(key) + extension;
try
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (FileStream fileStream = new FileStream(path, FileMode.Create))
@ -178,6 +181,11 @@ namespace Caching
fileStream.Write(buffer, 8, buffer.Length - 8);
}
}
catch (Exception ex)
{
Trace.TraceWarning("ImageFileCache: Writing file {0} failed: {1}", path, ex.Message);
}
}
}
public override void Set(CacheItem item, CacheItemPolicy policy)