カテゴリー
SugiBlog Webデザイナー・プログラマーのためのお役立ちTips

DNSキャッシュのクリア

コマンドプロンプトで

c:\> ipconfig /flushdns

を実行

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

と表示されればOK

2,331 views

BIND rndcエラー

・GUI上でサービス管理のnamedがエラーの時
・rndc querylogを実行するとエラーが出る時

【エラー内容】

rndc: connection to remote host closed
This may indicate that the remote server is using  an older version of the command protocol, this host is not authorized to connect, or the key is invalid.

【エラーの原因】
他のサーバで使用していたnamed.confファイルをコピーして流用したため。
rndc.keyの内容が異なるのでエラーになってしまう。

【エラー回避手順】

続きを読む…»

5,773 views

要素数の初期化なしに配列を生成(Listクラス)

予め要素数が決まっている場合は始めから配列を使用しますが、
可変の要素数の場合は、Listクラス(コレクション)を使用します。

using System.Collections.Generic;

// 型を指定して宣言
List<int> list = new List<int>();

// Addメソッドで値を追加
list.Add(0);

// ToArrayメソッドで配列化
int[] f = list.ToArray();
1,585 views

再帰を使わずにディレクトリをコピー(Queueクラス)

// Queueクラスを使用したコピー(再帰を使用しない方法)
Queue q = new Queue();
q.Enqueue(RootDirectory);

while (q.Count > 0)
{
    DirectoryInfo sourceDirectory = (DirectoryInfo)q.Dequeue();
    Target = sourceDirectory.FullName;

    foreach (string file in Directory.GetFiles(Target, pattern))
    {
    	//ここに各ファイルに対する処理を記述
    }

    DirectoryInfo[] dirs = sourceDirectory.GetDirectories();
    foreach (DirectoryInfo s in dirs)
    {
        q.Enqueue(s);
    }
}
// Queue : wrapper
1,924 views

連想配列を使用する

C#で連想配列を使用するにはHashtableを使います。

using System.Collections;

Hashtable table = new Hashtable();

table.Add("even", "偶数");
table.Add("odd", "奇数");

Console.WriteLine(table["even"]);
Console.WriteLine(table["odd"]);
1,739 views