From d3a564447d7358ad8fec60e397c06726cbe5cbdb Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 14 Aug 2020 14:14:59 +0200 Subject: [PATCH] gestione try/catch lettura file SVG da directory --- .../WebUserControls/cmp_OOIL_drawings.ascx.cs | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/NKC_WF/WebUserControls/cmp_OOIL_drawings.ascx.cs b/NKC_WF/WebUserControls/cmp_OOIL_drawings.ascx.cs index b0f39c0..882c62d 100644 --- a/NKC_WF/WebUserControls/cmp_OOIL_drawings.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_OOIL_drawings.ascx.cs @@ -34,35 +34,40 @@ namespace NKC_WF.WebUserControls private void fixDataBind() { string currPath = DrawingPath; - // in primis: fix directory - // visibile SOLO SE valore != null... - if (string.IsNullOrEmpty(currPath)) + try { - divDrawings.Visible = false; - } - else - { - divDrawings.Visible = true; - List elencoDisegni = new List(); - // verifico path assoluto... - if (!Path.IsPathRooted(currPath)) + // in primis: fix directory + // visibile SOLO SE valore != null... + if (string.IsNullOrEmpty(currPath)) { - currPath = Server.MapPath(currPath); + divDrawings.Visible = false; } - - // leggo da filesystem... - string[] elencoFiles = Directory.GetFiles(currPath, "*.svg"); - if (elencoFiles != null) + else { - foreach (var item in elencoFiles) + divDrawings.Visible = true; + List elencoDisegni = new List(); + // verifico path assoluto... + if (!Path.IsPathRooted(currPath)) { - elencoDisegni.Add(new imgData { imgName = Path.GetFileName(item), DrawPath = item.Replace(@"/",@"\") }); + 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(); } - // sistemo repeater - repDraw.DataSource = elencoDisegni; - repDraw.DataBind(); } + catch + { } } public class imgData