Archive for the 'C#' Category
ASP.net 发布的小问题
Exception Details: System.Data.SqlClient.SqlException: Failed to update database "C:\Inetpub\wwwroot\SSR\APP_DATA\ASPNETDB.MDF" because the database is read-only.
上面的例子通常发生在publish一个新开发的web application的时候,解决方法很简单:即修改App_Data这个目录的Security属性,加入用户"NETWORK SERVICE",并设置该用户可以对这个目录有Write权限。
C# LDAP Wrapper
Before you try to run the following code, please download Novel LDAP lib:
http://forge.novell.com/modules/xfcontent/downloads.php/ldapcsharp/ldapcsharp/CsharpLDAP-v2.1.10/
using System;
using System.Collections.Generic;
using System.Text;
using Novell.Directory.Ldap;
namespace LDAPUtility
{
class LDAPUtil
{
private string ldapHost = "ssuzdc3";
private int ldapPort = 389;
LdapConnection ldapConn = null;
private void Connect()
{
try
{
// Creating an LdapConnection instance
ldapConn = new LdapConnection();
// Connect function will create a socket connection to the server
ldapConn.Connect(ldapHost, ldapPort);
// Bind function with null user dn and password value will perform anonymous bind
// to LDAP server
ldapConn.Bind(null, null);
}
catch (Exception e)
{
// failed to connect to server
}
}
A New Release of Yet Another Browser
I've changed my plan, Yet Another Browser(YAB for short) still looks like its sibling, if a brower has a MS-Word-like look-and-feel, is it weird? So far, I think YAB will be helpful for some guys. If you're addicted to online photo communities, like Flickr, it can help you download photos when you go surfing, you don't need to save the photos manually. Just one click, all photos are flying to your disk on autopilot.
Features:
- You can tune up the opacity of main window
- Multi-tab support
- Right-click Close-Button to click all tabs, Left-Click just close one.
- Your can rename the title of YAB, it will show what you want on task bar.
- You can set the length of tab's title.
- Keep a list of websites you recently closed, you can easily undo it.
- Just one-click to download all images in current tab
- You can change the default direcotry where images will be saved.
Todo:
- Boss key
- Regular-Expressions for downloading images
- Password Protection
- Favorites
- Clear hisotry
- Clear dropdown list
- Self-update
- i18n
- Auto-downloading images when you go surfing, even you don't need one-click.
- You can replace the icon of YAB with another one.
Homepage for YAB: http://charry.org/m/myapps/YetAnotherBrowser
Stay tuned.
TabIndex != TabPages.IndexOf
TabControl的有个属性叫TabIndex,每个从Control派生来的控件都有这个属性,这个Tab是Tab键的顺序(MSDN说:A control with a lower tab index receives focus before a control with a higher index.)
我正好需要获取TabControl中某个Tab Page的Index。这些Tab Page保存在TabControl的TabPages中,它是一个集合,实现了IList接口,其中有个方法就是IndexOf (Determines the index of a specific item in the IList.)。
鬼使神差的,我把TabIndex属性当成了Tab Page在TabPages中的Index了,花费了N久时间,才发现问题所在。Tab Index和IndexOf,TabPages,这几个词放在一起,一不小心就会搞错,错误总在不经意间。
Yet Another Browser
If you're a office worker, are you afraid of being busted by your boss when surfing? I make this semi-browser from scratch, it resembles a regular Microsoft Office Suit Application, I'll add the following features to the browser, e.g.:
- Transparent window
- One-click to hide
- Download all images to your disk
- ...
I created it with C#, it's easy to create your own browser with its powerful components, everyone can make it if he wishes.
Download it! (Make sure you have the .NET Framework 2.0 installed on your computer)