随笔分类 -  .net

window8 metro 之 RSA
摘要://WinRT String str = "String To Encrypt"; IBuffer buf = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf16BE); AsymmetricKeyAlgorithmProvider asym = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1); ... 阅读全文

posted @ 2012-11-29 16:32 chuncn 阅读(1580) 评论(0) 推荐(0) 编辑

.net网络速度测试-转
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;using System.Diagnostics;namespace ConsoleApplication1{ public static class Ping { #region codes private const int TIME_OUT = 100; private const int PACKE... 阅读全文

posted @ 2011-11-16 01:27 chuncn 阅读(742) 评论(0) 推荐(0) 编辑

Winphone7之如何防止锁屏
摘要:winphone7 锁屏再恢复后,静态变量会变成null,等等,给使用带来极大的不便。为此,禁止锁屏对于这类应用是必需的,解决方法如何:<phone:PhoneApplicationPage x:Class="WPAntiScreenSaver.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone=& 阅读全文

posted @ 2011-05-11 17:35 chuncn 阅读(1195) 评论(0) 推荐(0) 编辑

BitmapImage与byte[]相互转换
摘要:byte[]转换为BitmapImage:public static BitmapImage ByteArrayToBitmapImage(byte[] byteArray) { BitmapImage bmp = null; try { bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = new MemoryStream(byteArray); bmp.EndInit(); } catch { bmp = null; } return bmp; }BitmapImage转换为byte[]:publ 阅读全文

posted @ 2010-12-10 16:33 chuncn 阅读(1075) 评论(0) 推荐(0) 编辑

转 很幽默的讲解六种Socket I/O模型
摘要:本文简单介绍了当前Windows支持的各种Socket I/O模型,如果你发现其中存在什么错误请务必赐教。一:select模型二:WSAAsyncSelect模型三:WSAEventSelect模型四:Overlapped I/O 事件通知模型五:Overlapped I/O 完成例程模型六:IOCP模型老陈有一个在外地工作的女儿,不能经常回来,老陈和她通过信件联系。他们的信会被邮递员投递到他们的... 阅读全文

posted @ 2010-07-27 16:22 chuncn 阅读(473) 评论(0) 推荐(0) 编辑

.net中的时区
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Collections... 阅读全文

posted @ 2010-07-19 19:25 chuncn 阅读(1236) 评论(0) 推荐(1) 编辑

socket 异常类型
摘要:对各种异常进行处理 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--///<summary>///根据错误号作出处理///</summary>///<paramname="error"></param>/... 阅读全文

posted @ 2010-04-27 19:25 chuncn 阅读(1240) 评论(0) 推荐(0) 编辑

引用 C# WinForm catch unhandled Exception
摘要:为了在WinForm中Catch所有没有Handle的Exception, 需要实现两个delegate.1. 用来catch所有界面线程的exception.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);2. 用来catch其... 阅读全文

posted @ 2010-04-24 18:54 chuncn 阅读(1027) 评论(0) 推荐(1) 编辑

C# Stream 和 byte[] 之间的转换
摘要:/// <summary> /// 将 Stream 转成 byte[] /// </summary> public byte[] StreamToBytes(Stream stream) { byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的... 阅读全文

posted @ 2010-03-18 15:57 chuncn 阅读(520) 评论(0) 推荐(0) 编辑

c# struct 变量 到 byte[] 变量的转换操作
摘要:using System.Runtime.InteropServices;#region 需要转换的结构 [StructLayout(LayoutKind.Sequential, Pack=1)]//struTest变量在内存中的对齐方式 (指针类型转换成功的必要条件)public struct struTest{ public int intId; public int intName; pub... 阅读全文

posted @ 2010-03-13 16:57 chuncn 阅读(3321) 评论(0) 推荐(0) 编辑

GetHashCode注意点-转
摘要:GetHashCode注意点: GetHashCode 方法的默认实现不保证针对不同的对象返回唯一值。而且,.NET Framework 不保证 GetHashCode 方法的默认实现以及它所返回的值在不同版本的 .NET Framework 中是相同的。因此,在进行哈希运算时,该方法的默认实现不得用作唯一对象标识符。 GetHashCode 方法可以由派生类型重写。值类型必须重写此方法,以提供适... 阅读全文

posted @ 2010-02-26 12:20 chuncn 阅读(282) 评论(0) 推荐(0) 编辑

DataTable 内部索引已损坏
摘要:由于性能原因,DataTable 没有设计成线程安全的,解决这个问题,可以在修改数据的时候采用lock语句 这里的修改包括: 1,添加,删除,修改DataTable的行 2,使用DataTable 的Select方法选择行,这会通过创建索引从而修改DataTable 3,在DataTable上创建DataViews ,也会导致重建索引 4,修改Sort属性也会导致DataTable的修改。... 阅读全文

posted @ 2009-12-07 13:32 chuncn 阅读(8262) 评论(0) 推荐(0) 编辑

让代码看起来更舒服:选择适合的字体-转
摘要:“让代码看起来更舒服”,看到这个标题,也许你会条件反射地以为我要讲“重构”或者“编码规范”等等。噢,可爱的开发人员,我们暂且不谈技术,只谈体验。让我们来装扮一下每天都要面对的Visual Studio,让代码看起来更舒服。下图展示了Visual Studio 2008默认的编辑器,为了让代码更加容易辨识,Visual Stud... 阅读全文

posted @ 2009-11-22 23:29 chuncn 阅读(5300) 评论(1) 推荐(0) 编辑

wcf中如何Host多个WCF服务?
摘要:如果用self-host的方式来加载服务的话,我们一般是用这样的代码:ServiceHosthost1=newServiceHost(typeof(UserService)); 问题是,如果当你的服务很多的时候这样做是不胜其烦的,今天在看Ingo Rammer(大名鼎鼎的《Advanced .Net Remoting》作者)的Blog的时候,看到了他解决这一问题的方法:一.服务配置在app.con... 阅读全文

posted @ 2009-09-14 08:11 chuncn 阅读(2551) 评论(2) 推荐(1) 编辑

使用HtmlAgilityPack批量抓取网页数据
摘要:相关软件点击下载登录的处理。因为有些网页数据需要登陆后才能提取。这里要使用ieHTTPHeaders来提取登录时的提交信息。抓取网页 HtmlAgilityPack.HtmlDocumenthtmlDoc;if(!string.IsNullOrEmpty(登录URL)){htmlDoc=htmlWeb.Load(登录URL,提交的用户验证信息,获取数据的网页URL);}else{htmlDoc=h... 阅读全文

posted @ 2009-09-07 01:39 chuncn 阅读(7407) 评论(0) 推荐(1) 编辑

Listview.Subitem.BackColor.ForeColor改变字体颜色和背景
摘要:注意事项: 一定要把listview的OwnerDraw属性设置为True(默认是False)。 当设置OwnerDraw = True后,FullRowSelect 、HideSelection 属性好象实效了。 添加DrawColumnHeader事件,绘制列标头用。 添加DrawSubItem事件,绘子项头用。代码如下: private void lvKeyPerson_DrawColum... 阅读全文

posted @ 2009-08-25 17:57 chuncn 阅读(3030) 评论(0) 推荐(0) 编辑

Edit the Context Menu
摘要:Oftentimes there is a need to modify, remove, or add context menu items to customize the ZedGraphControl context menu. This is handled by the ZedGraphControl.ContextMenuBuilder event as described belo... 阅读全文

posted @ 2009-08-10 14:18 chuncn 阅读(812) 评论(0) 推荐(0) 编辑

Managing Unhandled Exceptions in .NET
摘要:using System;using System.Threading;public class Form1 : System.Windows.Forms.Form{ // ...(omitted) /// /// The main entry point for the application. /// [STAThread] static void Main() { // Subscri... 阅读全文

posted @ 2009-08-04 09:45 chuncn 阅读(238) 评论(0) 推荐(0) 编辑

如何设置ListView控件中的列头的颜色!
摘要:ListView默认的列头的背景太单调,缺乏个性,想变的列头的背景色!实际上可以使用ListViewDrawColumnHeader事件自己画背景色,注意仅当 OwnerDraw 属性设置为 true 且 View 属性设置为 View. Details 时才引发此事件!不多说了,大家看代码,过程很简单:private void listView1_DrawColumnHeader(object ... 阅读全文

posted @ 2009-07-13 16:03 chuncn 阅读(10193) 评论(1) 推荐(0) 编辑

SQLDMO
该文被密码保护。

posted @ 2009-07-07 11:56 chuncn 阅读(11) 评论(0) 推荐(0) 编辑

导航