Skip to content

Commit 333f765

Browse files
authored
Added exception for non-existent directory in ImageLoader (dotnet#4831)
* Added exception for non-existant directory * Added comments * Update ImageLoader.cs
1 parent ef12e13 commit 333f765

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Microsoft.ML.ImageAnalytics/ImageLoader.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ internal ImageLoadingTransformer(IHostEnvironment env, string imageFolder = null
103103
internal ImageLoadingTransformer(IHostEnvironment env, string imageFolder = null, bool type = true, params (string outputColumnName, string inputColumnName)[] columns)
104104
: base(Contracts.CheckRef(env, nameof(env)).Register(nameof(ImageLoadingTransformer)), columns)
105105
{
106-
// Throws ArgumentException if given imageFolder path is invalid or empty. Note: imageFolder may be null in this case.
106+
// Throws ArgumentException if given imageFolder path is invalid or empty. Note: imageFolder may be null in this case.
107107
if (imageFolder != null)
108-
ImageFolder = Path.GetFullPath(imageFolder);
108+
if (Directory.Exists(imageFolder))
109+
ImageFolder = Path.GetFullPath(imageFolder);
110+
else
111+
throw new ArgumentException(String.Format("Directory \"{0}\" does not exist.", imageFolder));
109112
else
110113
ImageFolder = null;
111114
_useImageType = type;

0 commit comments

Comments
 (0)