📄 misclib.cs
字号:
using System;
namespace NiceTracker.Libraries
{
/// <summary>
/// Summary description for MiscLib.
/// </summary>
public class MiscLib
{
public MiscLib()
{
}
public static string ToFilename( string path, string file )
{
if ( path != "" )
{
if ( path[ path.Length-1] == '\\' )
return path + file;
else
return path + '\\' + file;
}
else
{
return file;
}
}
public static string Base64Encode(string data)
{
try
{
byte[] encData_byte = new byte[data.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
string encodedData = Convert.ToBase64String(encData_byte, 0, data.Length);
return encodedData;
}
catch(Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}
public static string Base64Decode(string data)
{
string result = "";
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
result = new String(decoded_char);
}
catch(Exception e)
{
//throw new Exception("Error in base64Decode" + e.Message);
}
return result;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -