A large amount of images in the same folder can have a negative impact in the global performance of the system.
You know that read or load a folder with thousand of files sometimes is impossible.
I solved adding this small code into ProductManager.cs
public static string GetImagePath(int IdDoc, string ImageRootPath)
{
try
{
double subdir1 = 0;
double subdir2 = 0;
string dir1 = null;
string dir2 = null;
int val = 0;
subdir1 = IdDoc / 65536;
val = Convert.ToInt32(subdir1);
dir1 = val.ToString("000");
//calcolo subdir2
subdir2 = IdDoc / 256;
while (subdir2 >= 256)
{
subdir2 = subdir2 - 256;
}
val = Convert.ToInt32(subdir2);
dir2 = val.ToString("000");
return ImageRootPath + "\\" + dir1 + "\\" + dir2 + "\\";
}
catch (Exception ex)
{
return "ERROR : " + ex.Message;
}
The logic of this function is the same logic of the Document Management Systems,
256 folders for each folder and 256 images for each folder.
All this for 3 levels (256x256x256)