improve stream disposal

This commit is contained in:
Luke Pulverenti
2013-05-07 14:57:27 -04:00
parent 156453cc42
commit baa779fb31
2 changed files with 9 additions and 15 deletions

View File

@@ -410,11 +410,13 @@ namespace MediaBrowser.Server.Implementations.IO
return false;
}
FileStream stream = null;
try
{
stream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
using (new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
//file is not locked
return false;
}
}
catch
{
@@ -424,14 +426,6 @@ namespace MediaBrowser.Server.Implementations.IO
//or does not exist (has already been processed)
return true;
}
finally
{
if (stream != null)
stream.Close();
}
//file is not locked
return false;
}
/// <summary>