Browse Source

WriteFile 自动创建目录

master
王厅 1 day ago
parent
commit
0220e48360
  1. 9
      Apewer/StorageUtility.cs

9
Apewer/StorageUtility.cs

@ -437,6 +437,9 @@ namespace Apewer
{ {
try try
{ {
var dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
File.WriteAllBytes(path, TextUtility.Bom); File.WriteAllBytes(path, TextUtility.Bom);
return true; return true;
} }
@ -451,6 +454,9 @@ namespace Apewer
var success = false; var success = false;
try try
{ {
var dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
var write1 = BytesUtility.Write(file, TextUtility.Bom); var write1 = BytesUtility.Write(file, TextUtility.Bom);
if (write1 == TextUtility.Bom.Length) if (write1 == TextUtility.Bom.Length)
{ {
@ -474,6 +480,9 @@ namespace Apewer
{ {
try try
{ {
var dir = Path.GetDirectoryName(path);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
File.WriteAllBytes(path, bytes); File.WriteAllBytes(path, bytes);
return true; return true;
} }

Loading…
Cancel
Save