using SteamWare; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace NKC_WF.WebUserControls { public partial class cmp_OOIL_drawings : BaseUserControl { protected void Page_Load(object sender, EventArgs e) { } public string DrawingPath { get { return hfDrawingPath.Value; } set { string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower(); string servBasePath = memLayer.ML.CRS("servBasePath").ToLower(); string fixPath = value.Replace(nestBasePath, servBasePath); hfDrawingPath.Value = fixPath; fixDataBind(); } } private void fixDataBind() { string currPath = DrawingPath; // in primis: fix directory // visibile SOLO SE valore != null... if (string.IsNullOrEmpty(currPath)) { divDrawings.Visible = false; } else { divDrawings.Visible = true; List elencoDisegni = new List(); // verifico path assoluto... if (!Path.IsPathRooted(currPath)) { currPath = Server.MapPath(currPath); } // leggo da filesystem... string[] elencoFiles = Directory.GetFiles(currPath, "*.svg"); if (elencoFiles != null) { foreach (var item in elencoFiles) { elencoDisegni.Add(new imgData { imgName = Path.GetFileName(item), DrawPath = item.Replace(@"/",@"\") }); } } // sistemo repeater repDraw.DataSource = elencoDisegni; repDraw.DataBind(); } } public class imgData { public string imgName { get; set; } = ""; public string DrawPath { get; set; } = ""; } } }