1
0
mirror of https://e.coding.net/circlecloud/CTZLauncher.git synced 2024-11-15 00:58:50 +00:00
CTZLauncher/KMCCC.Shared/Tools/UsefulTools.cs

54 lines
1.1 KiB
C#
Raw Normal View History

namespace KMCCC.Tools
{
#region
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#endregion
/// <summary>
/// 有用的东西
/// </summary>
public static class UsefulTools
{
public static string DoReplace(this string source, IDictionary<string, string> dic)
{
return dic.Aggregate(source, (current, pair) => current.Replace("${" + pair.Key + "}", pair.Value));
}
2015-07-31 14:27:55 +00:00
public static string GoString(this Guid? guid)
{
2015-07-31 14:27:55 +00:00
if (guid == null)
return "{}";
return guid.ToString().Replace("-", "");
}
public static void Dircopy(string source, string target)
{
var sourceDir = new DirectoryInfo(source);
if (!Directory.Exists(target))
{
Directory.CreateDirectory(target);
}
foreach (var file in sourceDir.GetFiles())
{
File.Copy(file.FullName, target + "\\" + file.Name, true);
}
foreach (var subdir in sourceDir.GetDirectories())
{
Dircopy(subdir.FullName, target + "\\" + subdir.Name);
}
}
#if DEBUG
public static string Print(this string str)
{
Console.WriteLine(str);
return str;
}
#endif
}
}