2008年2月29日

介绍一种使用md5计算hash值的方法。 下面的代码分别计算两个文件的散列值并比较两个文件是否相同。

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.IO;


        static bool fileCompare(string srcFilename, string destFilename)
        {
            try
            {
                //if file doesn't exist, will throw exception
                FileInfo srcFile = new FileInfo(srcFilename);
                FileInfo destFile = new FileInfo(destFilename);
                MD5 checksumCalculator = MD5.Create();
                byte[] srcChecksum = checksumCalculator.ComputeHash(srcFile.OpenRead());
                byte[] destChecksum = checksumCalculator.ComputeHash(destFile.OpenRead());
                if (srcChecksum.Length != destChecksum.Length)
                    return false;
                for (int index = 0; index < srcChecksum.Length; index++)
                {
                    if (srcChecksum[index] != destChecksum[index])
                        return false;
                }
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return false;
        }
posted @ 2008-02-29 22:19 magicdlf 阅读(77) | 评论 (0)编辑

2008年2月27日

http://www.cnblogs.com/Terrylee/archive/2005/12/13/295965.html
http://www.cnblogs.com/bit-sand/archive/2008/01/31/abstract_factory.html
posted @ 2008-02-27 17:19 magicdlf 阅读(37) | 评论 (0)编辑

2008年2月25日

打开VSTFS时发现Team Foundation Server不能列出所有的Team projects. 这是由于TFS的cache在作怪,删除TFS的缓存文件后,症状消除

Deleted the TFS cache folder (“c:"documents and settings"[username]"local settings"application data"microsoft"team foundation”), and restart VSTS.

posted @ 2008-02-25 16:42 magicdlf 阅读(21) | 评论 (0)编辑
登录Team foundation server,然后Team->Project Alerts, 设置接收通知的email地址即可
posted @ 2008-02-25 16:40 magicdlf| 编辑

2008年1月31日

http://www.csharphelp.com/archives3/archive578.html
http://www.codeproject.com/KB/dotnet/SettingWallpaperDotNet.aspx

核心部分代码:
using System.Runtime.InteropServices;

        public class WinAPI
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
            public const int SPI_SETDESKWALLPAPER = 20;
            public const int SPIF_SENDCHANGE = 0x2;
            public const int SPIF_UPDATEINIFILE = 0x01;

        }

         public void changeWallpaper(string path)
        {
            Microsoft.Win32.RegistryKey rkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop",true);
            try
            {

                if (rkey != null)
                {
                    string currentWallpaper = rkey.GetValue(@"Wallpaper") as string;
                    if (currentWallpaper != null)
                    {
                        //key exists;
                        //rkey.SetValue(@"Wallpaper", textBox1.Text);
                        rkey.SetValue(@"WallpaperStyle", 1.ToString());
                        rkey.SetValue(@"TileWallpaper", 0.ToString());
                        string fileName = path;
                        if (fileName.ToLower().EndsWith(@".jpg"))
                        {
                            fileName = jepg2bmp(fileName);
                        }
                        //check file exists;
                        int nResult = WinAPI.SystemParametersInfo(WinAPI.SPI_SETDESKWALLPAPER, 0, fileName, WinAPI.SPIF_SENDCHANGE | WinAPI.SPIF_UPDATEINIFILE);
                        Console.WriteLine(nResult);
                    }
                }
            }
            catch { }
        }
posted @ 2008-01-31 00:17 magicdlf 阅读(44) | 评论 (0)编辑

导航

<2008年8月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

统计

与我联系

搜索

 

常用链接

留言簿

我的标签

随笔档案

最新评论

阅读排行榜

评论排行榜