
C#
zhleiyang
寻找乐趣,做一些有趣的事情,增加财富和提高名声。
展开
-
OssMetro网盘简介及源代码
一 简介 OssMetro网盘是基于阿里云OSS服务开发的一款界面美观,功能强大的网盘应用。界面采用metro风格,使用在官网.Net SDK基础上开发的OSS .NET 4.5 SDK。运行需要安装.NET 4.5 Framework。下载地址: 点击打开链接代码地址:https://github.com/ZhongleiYang/OssMetroClient原创 2012-10-16 22:50:05 · 14425 阅读 · 1 评论 -
License Key Generator
http://licensekeygenerator.codeplex.com/转载 2012-06-12 18:08:38 · 2408 阅读 · 0 评论 -
How to: Create a Binding in Code
http://msdn.microsoft.com/en-us/library/ms742863.aspxpublic class MyData : INotifyPropertyChanged{ private string myDataProperty; public MyData() { } public MyData(DateTime date转载 2012-06-12 17:51:23 · 398 阅读 · 0 评论 -
How to detect Windows 64 bit platform with .net?
http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-netIntPtr.Size won't return the correct value if running in 32-bit .NET Framework 2.0 on 64-bit Windows转载 2012-06-12 18:04:47 · 428 阅读 · 0 评论 -
How to Execute a Command in C# ?
http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-CThis article will help you to execute a command in C#, just like we execute a command using the Windows command promptAdd转载 2012-05-04 09:25:42 · 829 阅读 · 0 评论 -
uninstall software using uninstallString
1. read uninstallString2. parse the string3. run command line原创 2012-05-04 09:28:44 · 1057 阅读 · 0 评论 -
Cast int to Enum in C#
http://stackoverflow.com/questions/29482/cast-int-to-enum-in-c-sharpFrom a string:YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString); From an int:YourEnum foo = (YourEnu转载 2012-04-19 13:07:41 · 1043 阅读 · 0 评论 -
Why is the Asynchronous mode is better than the Synchronous one when handling clients requests?
http://stackoverflow.com/questions/3161916/why-is-the-asynchronous-mode-is-better-than-the-synchronous-one-when-handling-clYes, asynchronous requests can often be handled without the expense o转载 2012-05-04 09:20:50 · 457 阅读 · 0 评论 -
FileStream Read File
http://www.csharp-examples.net/filestream-read-file/FileStream Read File [C#]This example shows how to safely read file using FileStream in C#. To be sure the whole file is correctly read,转载 2012-04-19 13:08:24 · 2861 阅读 · 0 评论 -
All about abstract classes
http://www.codeproject.com/Articles/6118/All-about-abstract-classesIntroductionAbstract classes are one of the essential behaviors provided by .NET. Commonly, you would like to make classe转载 2012-04-19 13:06:26 · 458 阅读 · 0 评论 -
C# 获取当前目录的各种方法
Application.StartupPath;Environment.SpecialFolder.ApplicationData Environment.SpecialFolder命名空间可以获取很多特定的路径目录。 Environment.SpecialFolder. ApplicationData CommonApplicationData转载 2012-04-13 17:13:35 · 11836 阅读 · 0 评论 -
c# load dll dynamic and run the method
Assembly testDLL = Assembly.LoadFile(Directory.GetCurrentDirectory() + @"\testDll.dll"); Type type = testDLL.GetType("testDll.TestClass"); object instanceOfMyType = Activato原创 2012-04-11 16:22:33 · 726 阅读 · 0 评论 -
How to maintain user.config settings when upgrading
http://bytes.com/topic/c-sharp/answers/522191-how-maintain-user-config-settings-when-upgradingAdd a Setting to your project called ApplicationVersion, then use code likethe following in the star转载 2012-04-10 17:57:28 · 391 阅读 · 0 评论 -
convert byte[4] to int32
int length = BitConverter.ToInt32(buffer, 0); //buffer is byte[]原创 2012-03-23 11:52:19 · 757 阅读 · 1 评论 -
在C#里调试c++代码
1.在项目的"debug"属性里"Enable unmanaged code debugging"打勾2.在debug目录下,加入c++ dll的.pdb文件3.在module里加载这个.pdb参考:http://stackoverflow.com/questions/9462211/how-to-debug-the-code-inside-the-dll原创 2012-03-15 18:41:02 · 955 阅读 · 0 评论 -
search son or parent process
参考:http://stackoverflow.com/questions/2531837/how-can-i-get-the-pid-of-the-parent-process-of-my-application Process searchSonProcess(int processId) { var myId =原创 2012-06-12 18:02:27 · 569 阅读 · 0 评论 -
Caliburn Micro
Caliburn Micro是一个mvvm的框架可以应用于WPF,Silverlight,WP7。具体资料:https://www.mindscapehq.com/blog/index.php/2012/01/12/caliburn-micro-part-1-getting-started/http://www.cnblogs.com/Zhouyongh/archive原创 2012-08-02 10:29:45 · 2600 阅读 · 0 评论 -
10分钟了解C#中的协变和逆变
http://www.2cto.com/kf/201206/136883.html 作者:cnn237111说十分钟可能有哗众取宠的嫌疑,本人写这个博客,话了半天时间,查阅了很多资料才完成,因此要弄懂协变逆变的本质,可能要多花点时间。-------------------------------------------------------------------------转载 2013-03-13 11:51:26 · 1260 阅读 · 0 评论 -
c#生成大量随机码
最近公司需要一个生成大量随机码用于数字销售。代码如下: class Program { static void Main(string[] args) { StreamWriter swriter = new StreamWriter("1.txt", true); for (int i = 0; i原创 2013-01-17 15:36:27 · 1687 阅读 · 2 评论 -
Mono在国内的发展历程(相关文章汇总)
转自:http://www.cnblogs.com/shanyou/archive/2012/07/28/2612919.htmlMono在国内的发展历程(相关文章汇总)一则新闻《软件服务提供商Xamarin融资1200万美元》,更详细的内容可以看Xamarin的官方博客Xamarin raises $12M to help you make better ap转载 2012-12-28 17:50:17 · 1442 阅读 · 0 评论 -
阿里云OSS SDK(.NET4.5)开源代码
参加阿里云开发比赛,准备用C#做个oss客户端,发现原来的.net开发包不太好用。正逢微软发布vs2012和 .net4.5,在原来的.net sdk代码基础上重写了SDK。接口与原来的SDK基本保持一致。目前sdk还处于测试和代码优化阶段,我正在用它做个metro风格的客户端。欢迎大家测试和建议。新SDK API基于TPL (Task Parallel Library)。增加原创 2012-09-11 15:30:31 · 9735 阅读 · 2 评论 -
agsxmpp client 连接openfire
agsxmpp 连接openfire 需修改源代码如下:1. 修改 agsxmpp 里的Mechanism.cs 里 //case "DIGEST-MD5": //注释掉 case "DIGEST-MD5": 使plain 变为 默认设置 //return Mechanism原创 2012-09-10 16:21:43 · 5128 阅读 · 1 评论 -
xml的序列化和反序列化
xml的序列化和反序列化简单例子如下: [XmlRoot("Person")] public class Person { [XmlElement("Name")] public string Name; [XmlElement("Age")] public int Age; } cl原创 2012-09-05 19:30:13 · 1072 阅读 · 0 评论 -
try-catch-finally
try区域里使用资源,catch区域处理try抛出的异常,finally释放资源。finally 是无论是否有异常都执行的语句块。 using System; using System.IO; public class TestTryFinally { public static void Main() {原创 2012-09-05 19:14:39 · 607 阅读 · 0 评论 -
Inversion of control (控制反转)
IOC实际上就是为了解耦,减小对象之间的依赖。看下面的图中代码,clsCustomer类依赖clsAdderess类。这样代码会有一个问题,clsAdderess类改了代码以后,clsCustomer类同样需要重编译。解决这个问题,要引入接口对他们进行解耦。比如 构造函数的方法容器实际上这就是mef模式的解决方法。ME原创 2012-08-22 18:12:39 · 720 阅读 · 0 评论 -
.net 4.5的异步编程
.net 4.5 最大的功能就是对异步编程的改进,增加了await async 关键字让异步编程变的和同步编程一样简单。这个模式是基于task parallel library实现的。下面看下一个简单的wpf程序: async private void Button_Click_1(object sender, RoutedEventArgs e) {原创 2012-08-22 12:45:33 · 1531 阅读 · 0 评论 -
c# HttpClient上传和下载的进度显示问题
WebClient中有DownloadProgressChangedEventHandler等事件可以响应http请求(或者其他web请求)的进度。在c# 5.0中,HttpClient的函数都是以Task异步函数存在,没有事件可以回调显示上传或下载的进度。我找了很久,终于发现ProgressMessageHandler 可以解决这个问题,链接:http://msdn.microsoft.原创 2012-08-31 14:05:42 · 10986 阅读 · 4 评论 -
HttpClient in .net Framework 4.5
转自书:C# 5.0 IN A NUTSHELL (待翻译)HttpClientHttpClient is new to Framework 4.5 and provides another layer on top ofHttpWebRequest and HttpWebResponse. It was written in response to the growth转载 2012-08-21 21:06:49 · 6450 阅读 · 2 评论 -
c#进程间通信----管道server端
管道是进程间通信的一种方法。参考:http://stackoverflow.com/questions/4451805/windows-named-pipe-issue-error-code-233-alternates/4475816#4475816http://www.codeproject.com/Articles/34073/Inter-Process-Commun原创 2012-03-09 11:51:19 · 1238 阅读 · 0 评论 -
c#程序的远程调试
1. 在远程机器上拷贝msvsmon.exe所在的x86文件夹2. 用管理员权限打开msvsmon.exe3. 在本机上点击vs的tools,attach process;4. 找到需要调试的远程机器名,选择managed(v 4.0), 找到程序列表,attach。注意: 1 两台机器必须用同一账号登录,且是管理员权限,在同一域中。 2 关掉两台机器的防火原创 2012-07-02 19:38:33 · 1433 阅读 · 0 评论 -
c#中的多线程异常处理
1.对于Thread操作的异常处理public static void Main(){ try { new Thread (Go).Start(); } catch (Exception ex) { // We'll never get here! Console.WriteLine ("Exception!"); }}原创 2012-08-29 15:33:52 · 11901 阅读 · 0 评论 -
Inter-Process Communication (IPC) Introduction and Sample Code
转自: http://www.codeproject.com/Articles/34073/Inter-Process-Communication-IPC-Introduction-and-SIntroductionInter-Process Communication (IPC) is a set of techniques for the exchange of data among转载 2012-03-02 18:03:27 · 1964 阅读 · 0 评论 -
c# INI文件处理
转载:http://www.codeproject.com/Articles/1966/An-INI-file-handling-class-using-CAn INI file handling class using C#IntroductionI created a C# class Ini which exposes 2 functions from KER转载 2012-02-28 12:02:59 · 591 阅读 · 0 评论 -
C# Serialize List Tutorial
转自:http://www.dotnetperls.com/serialize-listWhat is an easy way to persist or serialize a List instance to the disk? The problem is that you have a List of C# objects you want to write or se转载 2012-02-22 10:14:31 · 1969 阅读 · 0 评论 -
文件夹的删除和转移
1.删除:DirectoryInfo 类里有个重载的递归删除包括子文件夹文件的函数 public void Delete(bool recursive);使用如下: public static void DeleteFolder(string dir) { DirectoryInfo dirInfo = new Director原创 2011-12-22 15:27:47 · 740 阅读 · 0 评论 -
xmpp IM
准备做一个IM.1 用agsxmpp库做客户端开发2 openfire做服务器软件。按照网上的教程,安装了openfile,配置了本地的数据库mysql。安装了spark客户端,测试了下,成功通讯。但是用agsxmpp的miniClinet测试,却登录不成功。看了很多帖子,没找到解决方案。最后去agsxmpp论坛上发帖子求助了。等别人解答了。原创 2011-12-21 19:54:43 · 529 阅读 · 0 评论 -
String Format for Double [C#]
The following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString.Digits after decimal pointTh转载 2011-12-21 19:54:27 · 481 阅读 · 0 评论 -
json的序列化
参照:http://pietschsoft.com/post/2008/02/NET-35-JSON-Serialization-using-the-DataContractJsonSerializer.aspx转载 2011-12-20 11:37:28 · 258 阅读 · 0 评论 -
安装包制作
参照 http://msdn.microsoft.com/zh-cn/library/z2f953x9.aspx转载 2011-12-20 11:43:00 · 277 阅读 · 0 评论 -
.NET 线程池编程技术
http://blog.youkuaiyun.com/educast/article/details/3018296首先声明这篇关于线程池的文章不是我的原创,我是转载的源地址是http://www.cnblogs.com/wildman/archive/2008/08/22/1274170.html 摘要深度探索 Microsoft .NET提供的线程池,揭示什么情况下你需要用线程池以及转载 2011-12-20 11:41:45 · 520 阅读 · 0 评论