public static bool IsBase64String(string s)
{
if ((s.Length % 4) != 0)
{
return false;
}
try
{
MemoryStream stream = new MemoryStream(Convert.FromBase64String(s));
return true;
}
catch
{
return false;
}
}
keys: c#, base64, crypto,
public static bool IsBase64String(string s)
{
if ((s.Length % 4) != 0)
{
return false;
}
try
{
MemoryStream stream = new MemoryStream(Convert.FromBase64String(s));
return true;
}
catch
{
return false;
}
}
public string AssemblyGuidString(System.Reflection.Assembly assembly)
{
object[] objects =
assembly.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);
if (objects.Length > 0)
{
return ((System.Runtime.InteropServices.GuidAttribute)objects[0]).Value;
}
else
{
return String.Empty;
}
}
delegate void updateLabelTextDelegate(string newText);
private void updateLabelText(string newText)
{
if (label1.InvokeRequired)
{
// this is worker thread
updateLabelTextDelegate del = new updateLabelTextDelegate(updateLabelText);
label1.Invoke(del, new object[] { newText });
}
else
{
// this is UI thread
label1.Text = newText;
}
}
Keys: asp.net, webrequest, proxy.
<system.net>
<defaultproxy>
<proxy
usesystemdefault="false"
proxyaddress="http://192.168.1.1:3128"
bypassonlocal="true"
</proxy>
</defaultproxy>
</system.net>
public static byte[] StringToByteArray(string inputString)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(inputString);
}
private void test()
{
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
Hashtable hashtable = new Hashtable();
ArrayList m_languages = new ArrayList();
hashtable.Add("", "Default");
m_languages.Add("");
for (int i = 0; i < cultures.Length; i++)
{
CultureInfo info = cultures[i];
if (info.Name != "")
{
hashtable.Add(info.Name, info.DisplayName);
}
}
}