fixes #255 - Access to the path is denied.

pull/702/head
Luke Pulverenti 12 years ago
parent 2bb518027f
commit a0ed6ec96e

@ -374,6 +374,14 @@ namespace MediaBrowser.Server.Implementations.Providers
try
{
// If the file already exists but is hidden, the below save will throw an UnauthorizedAccessException
var existingFileInfo = new FileInfo(localPath);
if (existingFileInfo.Exists && existingFileInfo.Attributes.HasFlag(FileAttributes.Hidden))
{
existingFileInfo.Delete();
}
using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous))
{
await img.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false);

Loading…
Cancel
Save