From 04b73253e9543b12b36b64dec9bbc4f8f8ff2ca1 Mon Sep 17 00:00:00 2001 From: cjy Date: Wed, 20 Nov 2024 17:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DS.WMS.Core/Op/Method/OpFileService.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/OpFileService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/OpFileService.cs index 96ba365b..8f75eacd 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/OpFileService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/OpFileService.cs @@ -241,8 +241,8 @@ namespace DS.WMS.Core.Op.Method } try { - //if (!Directory.Exists(dirAbs)) - // Directory.CreateDirectory(dirAbs); + if (!Directory.Exists(dirAbs)) + Directory.CreateDirectory(dirAbs); // 先存库获取Id var id = SnowFlakeSingle.Instance.NextId(); var fileSaveName = $"{id}{fileSuffix}".ToLower(); @@ -270,17 +270,20 @@ namespace DS.WMS.Core.Op.Method } filesPath.Add(fileSaveName); } - catch (UnauthorizedAccessException ex) + catch (IOException ex) { - return await Task.FromResult(DataResult.Failed("UnauthorizedAccessException "+ ex.Message)); + throw new Exception("IOException " + ex.Message); + //return await Task.FromResult(DataResult.Failed("IOException " + ex.Message)); } - catch (IOException ex) + catch (UnauthorizedAccessException ex) { - return await Task.FromResult(DataResult.Failed("IOException " + ex.Message)); + throw new Exception("UnauthorizedAccessException " + ex.Message); + //return await Task.FromResult(DataResult.Failed("UnauthorizedAccessException "+ ex.Message)); } catch (Exception ex) { - return await Task.FromResult(DataResult.Failed("Exception " + ex.Message)); + throw new Exception("Exception " + ex.Message); + //return await Task.FromResult(DataResult.Failed("Exception " + ex.Message)); } } return await Task.FromResult(DataResult.Success(string.Join(",", filesPath.ToArray())));