You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
|
|
namespace MHFOldEquipQuestFix |
|
{ |
|
public class FileHelper |
|
{ |
|
public static bool LoadFile(string FilePath, out byte[] data) |
|
{ |
|
using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read)) |
|
{ |
|
try |
|
{ |
|
byte[] buffur = new byte[fs.Length]; |
|
fs.Read(buffur, 0, (int)fs.Length); |
|
fs.Close(); |
|
data = buffur; |
|
return true; |
|
} |
|
catch (Exception ex) |
|
{ |
|
data = null; |
|
return false; |
|
} |
|
} |
|
} |
|
|
|
public static string[] GetDirFile(string Path) |
|
{ |
|
return Directory.GetFiles(Path); |
|
} |
|
|
|
public static byte[] String2Byte(string value) |
|
{ |
|
return Encoding.Default.GetBytes(value); |
|
} |
|
public static bool SaveFile(string FilePath, byte[] buffer) |
|
{ |
|
try |
|
{ |
|
//创建一个文件流 |
|
using (FileStream wfs = new FileStream(FilePath, FileMode.Create)) |
|
{ |
|
//将byte数组写入文件中 |
|
wfs.Write(buffer, 0, buffer.Length); |
|
//所有流类型都要关闭流,否则会出现内存泄露问题 |
|
wfs.Close(); |
|
return true; |
|
} |
|
} |
|
catch |
|
{ |
|
return false; |
|
} |
|
} |
|
} |
|
}
|
|
|