foreach (var ni in NetworkInterface.GetAllNetworkInterfaces())
{
//var wzc = ni as WirelessZeroConfigNetworkInterface;
//if (wzc != null)
//{
// MessageBox.Show("WZC Signal: " +
wzc.SignalStrength.Decibels+":"+wzc.Name);
// StrengthType st = wzc.SignalStrength.Strength;
// switch (st)
// {
// case StrengthType.NoSignal:
// break;
// }
// continue;
//}
var wni = ni as WirelessNetworkInterface;
if(wni != null)
{
StrengthType strength = wni.SignalStrength.Strength;
switch (strength)
{
case StrengthType.NoSignal: Program.batteryandtime.WifiUpdate(0);
label1.Text = "NoSignal";
wifi_strength = 0;
break;
case StrengthType.NotAWirelessAdapter:
Program.batteryandtime.WifiUpdate(0);
label1.Text = "NotAWirelessAdapter";
wifi_strength = 0;
break;
case StrengthType.Excellent:Program.batteryandtime.WifiUpdate(3);
label1.Text = "Excellent";
wifi_strength = 3;
break;
case StrengthType.VeryGood:Program.batteryandtime.WifiUpdate(3);
label1.Text = "VeryGood";
wifi_strength = 3;
break;
case StrengthType.Good:Program.batteryandtime.WifiUpdate(2);
label1.Text = "Good";
wifi_strength = 2;
break;
case StrengthType.Low: Program.batteryandtime.WifiUpdate(1);
label1.Text = "Low";
wifi_strength = 1;
break;
case StrengthType.VeryLow: Program.batteryandtime.WifiUpdate(1);
label1.Text = "VeryLow";
wifi_strength = 1;
break;
}
continue;
}
MessageBox.Show("No signal info available");
}
Note : To use OpenNetCF.Net.dll (2.3.12004.0)
Binary File Uploading by Web Serviece
[WebMethod]
public void UploadLogFile(byte[] buffer, string filename)
{
if (!Directory.Exists("D:\\EEMS\\EHTLog\\" + DateTime.Now.ToString("yyyyMM")))
{
Directory.CreateDirectory("D:\\EEMS\\EHTLog\\" +
DateTime.Now.ToString("yyyyMM"));
}
BinaryWriter binWriter = new
BinaryWriter(File.Open("D:\\EEMS\\EHTLog\\" +
DateTime.Now.ToString("yyyyMM") + "\\" + filename, FileMode.CreateNew,
FileAccess.ReadWrite));
binWriter.Write(buffer);
binWriter.Close();
}
public void UploadLogFile(byte[] buffer, string filename)
{
if (!Directory.Exists("D:\\EEMS\\EHTLog\\" + DateTime.Now.ToString("yyyyMM")))
{
Directory.CreateDirectory("D:\\EEMS\\EHTLog\\" +
DateTime.Now.ToString("yyyyMM"));
}
BinaryWriter binWriter = new
BinaryWriter(File.Open("D:\\EEMS\\EHTLog\\" +
DateTime.Now.ToString("yyyyMM") + "\\" + filename, FileMode.CreateNew,
FileAccess.ReadWrite));
binWriter.Write(buffer);
binWriter.Close();
}
Convert UT8 to GB2312 (Chinese Encoding)
string GBInfo = string.Empty;
Encoding utf8 = Encoding.UTF8;
Encoding gb2312 = Encoding.GetEncoding("gb2312");
byte[] UnicodeBytes = utf8.GetBytes(str);
byte[] AscIIBytes = Encoding.Convert(utf8, gb2312, UnicodeBytes);
char[] AscIIChars = new char[gb2312.GetCharCount(AscIIBytes, 0,
AscIIBytes.Length)];
gb2312.GetChars(AscIIBytes, 0, AscIIBytes.Length, AscIIChars, 0);
return AscIIBytes;
Encoding utf8 = Encoding.UTF8;
Encoding gb2312 = Encoding.GetEncoding("gb2312");
byte[] UnicodeBytes = utf8.GetBytes(str);
byte[] AscIIBytes = Encoding.Convert(utf8, gb2312, UnicodeBytes);
char[] AscIIChars = new char[gb2312.GetCharCount(AscIIBytes, 0,
AscIIBytes.Length)];
gb2312.GetChars(AscIIBytes, 0, AscIIBytes.Length, AscIIChars, 0);
return AscIIBytes;
Subscribe to:
Posts (Atom)