Browse Source

[fix] Directory.GetCurrentDirectory 方法不是真正的获取应用程序的当前方法,而是执行命令所在目录。具体修改查阅代码。

HuiZhou
fajiao 2 years ago
parent
commit
7bfe22e623
  1. 2
      AutoWeightServer/Center/DeviceCenter.cs
  2. 2
      AutoWeightServer/UI/FrmMainServer.cs
  3. 3
      EC.Service/Transport/PhotoService.cs
  4. 10
      EC.Utils/CommonUtil.cs

2
AutoWeightServer/Center/DeviceCenter.cs

@ -318,7 +318,7 @@ namespace EC.AutoWeightServer.Center
return; return;
YkPosManager.InitPrinter(); YkPosManager.InitPrinter();
var bmpPath = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine("Img", "logo.bmp")); var bmpPath = Path.Combine(CommonUtil.GetWorkDirectory(), Path.Combine("Img", "logo.bmp"));
YkPosManager.SetAlign(1);//居中 YkPosManager.SetAlign(1);//居中
YkPosManager.PrintRasterBmp(new StringBuilder(bmpPath));//打印图片 YkPosManager.PrintRasterBmp(new StringBuilder(bmpPath));//打印图片

2
AutoWeightServer/UI/FrmMainServer.cs

@ -994,7 +994,7 @@ namespace EC.AutoWeightServer.UI
private void CheckPhotoSaveCycle() private void CheckPhotoSaveCycle()
{ {
var now = DateTime.Now; var now = DateTime.Now;
var workPath = Directory.GetCurrentDirectory(); var workPath = CommonUtil.GetWorkDirectory();
var capDir = new DirectoryInfo(Path.Combine(workPath, "cap")); var capDir = new DirectoryInfo(Path.Combine(workPath, "cap"));
if (!capDir.Exists) if (!capDir.Exists)
return; return;

3
EC.Service/Transport/PhotoService.cs

@ -1,5 +1,6 @@
using EC.Entity.Transport; using EC.Entity.Transport;
using EC.Service.Base; using EC.Service.Base;
using EC.Utils;
using System; using System;
using System.IO; using System.IO;
@ -39,7 +40,7 @@ namespace EC.Service.Transport
public static string GetSaveImagePath(string license) public static string GetSaveImagePath(string license)
{ {
var now = DateTime.Now; var now = DateTime.Now;
var workPath = Directory.GetCurrentDirectory(); var workPath = CommonUtil.GetWorkDirectory();
var subPath = Path.Combine(new string[] { "cap", now.ToString("yyyy"), now.ToString("MM"), now.ToString("dd") }); var subPath = Path.Combine(new string[] { "cap", now.ToString("yyyy"), now.ToString("MM"), now.ToString("dd") });
//var subPath = Path.Combine("cap", now.ToString("yyyy-MM-dd")); //var subPath = Path.Combine("cap", now.ToString("yyyy-MM-dd"));
var fileFolder = Path.Combine(workPath, subPath); var fileFolder = Path.Combine(workPath, subPath);

10
EC.Utils/CommonUtil.cs

@ -2,6 +2,7 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.IO; using System.IO;
using System.Reflection;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace EC.Utils namespace EC.Utils
@ -216,5 +217,14 @@ namespace EC.Utils
return null; return null;
} }
} }
private static string workDirectory;
public static string GetWorkDirectory()
{
workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) :workDirectory;
return workDirectory;
}
} }
} }
Loading…
Cancel
Save