diff --git a/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs b/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs
index d105fd750..782590892 100644
--- a/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs
+++ b/src/Orchard/FileSystems/Media/FileSystemStorageProvider.cs
@@ -271,17 +271,18 @@ namespace Orchard.FileSystems.Media {
/// The relative path to the file to be deleted.
///
private IEnumerable ListProfiles(string path) {
+ var directoryInfo = new DirectoryInfo(MapStorage("_Profiles"));
+
+ if (!directoryInfo.Exists) return Enumerable.Empty();
+
var filenameWithExtension = Path.GetFileName(path) ?? "";
var urlpath = GetPublicUrl(path);
var fileLocation = urlpath.Substring(0, urlpath.Length - filenameWithExtension.Length);
var hashpath = fileLocation.GetHashCode().ToString("x").ToLowerInvariant();
- DirectoryInfo directoryInfo = new DirectoryInfo(MapStorage("_Profiles"));
- return directoryInfo.Exists ?
- directoryInfo
- .GetFiles(filenameWithExtension, SearchOption.AllDirectories)
- .Where(x => x.Directory.Name.Equals(hashpath)) :
- Enumerable.Empty();
+ return directoryInfo
+ .GetFiles(filenameWithExtension, SearchOption.AllDirectories)
+ .Where(x => x.Directory.Name.Equals(hashpath));
}
///