public void loadImages(MapPackage pkg) { Hashtable parts = new Hashtable(); try { string pathToParts = this.mapsDir + "\\zoom_" + pkg.getZoom() + "\\" + pkg.getName() + "\\parts"; DirectoryInfo partsDirInfo = new DirectoryInfo(pathToParts); string searchPattern = "*"; if (pkg.getPartsFormat() != "") { searchPattern += "." + pkg.getPartsFormat(); } foreach (FileInfo partFileInfo in partsDirInfo.GetFiles(searchPattern)) { String partFileName = partFileInfo.Name; // remove extension char[] s = ".".ToCharArray(); String name = partFileName.Split(s)[0]; // get part coordinates (not geografical) s = "_".ToCharArray(); String[] pointStr = name.Split(s); // NOTE: part images are named inversely, row number is first then col number Point p = new Point(Convert.ToInt32(pointStr[1]), Convert.ToInt32(pointStr[0])); Bitmap img = new Bitmap(pathToParts + "\\" + partFileInfo.ToString()); parts[p] = img; } } catch (Exception e) { Debug.WriteLine("MapPkgRepository: loadImages: error during images load!"); throw new MapPkgRepositoryException("error during images load", e); } try { // after successfully loading parts set them in map pkg foreach (DictionaryEntry part in parts) { pkg.setPart((Point)part.Key, (Bitmap)part.Value); } } catch (Exception e) { pkg.freeParts(); Debug.WriteLine("MapPkgRepository: loadImages: error during images put to map pkg!"); throw new MapPkgRepositoryException("error during images put to map pkg", e); } }