private void Initial() { string strFilesPath = ""; string strSelectPath = ""; string strFilePath = Server.MapPath("."); int index = strFilePath.LastIndexOf("Samples"); if (index != -1) { strFilePath = strFilePath.Substring(0, index) + "Images\\"; } else { strFilePath = strFilePath + "\\Images\\DemoImages\\"; } string[] files = Directory.GetFiles(strFilePath); if (files != null && files.Length > 0) { bool isFirst = true; for (int i = 0; i < files.Length; i++) { string strFileExt = files[i].Substring(files[i].LastIndexOf('.') + 1).ToLower(); if (!BarcodeMode.IfFileExt(strFileExt)) { continue; } if (isFirst) { SetFilesPath(files[i], true, ref strFilesPath); strSelectPath = strFilesPath; isFirst = false; } else { SetFilesPath(files[i], false, ref strFilesPath); } } } hide_allImgURL.Value = strFilesPath; hide_ImgFileName.Value = strSelectPath; Image1.ImageUrl = strSelectPath; }