14 Aralık 2008 Pazar

Sistemi beklemeye alma

C#
System.Threading.Thread.Sleep(75);

Java
java.lang.Thread.sleep(75);

C/C++
delay(75);
_sleep(100);

// verilen parametre milisaniye cinsinden
// 1000 ms=1 saniye .

11 Aralık 2008 Perşembe

Dosyaya Veri yaz-oku

private static void Dosya_Yaz()
{
string hedef_dosya = @"C:\Documents and Settings\ADMİN\Belgelerim\School\Algorithm Analys\Yeni Metin Belgesi2.txt";
FileStream fsOutput = new FileStream(hedef_dosya, FileMode.Create, FileAccess.Write);
StreamWriter srOutput = new StreamWriter(fsOutput);
for (int nIndex = 0; nIndex < 5; nIndex++)
{
// hedef dosyaya satır yazma
srOutput.WriteLine("selamun aleykum");
}
srOutput.Close();
fsOutput.Close();
}


===========================================================================

private static void Dosya_Oku()
{
string hedef_dosya = @"C:\Documents and Settings\ADMİN\Belgelerim\School\Algorithm Analys\Yeni Metin Belgesi2.txt";
string okunan="";
FileStream fsinput = new FileStream(hedef_dosya,FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fsinput);

int count=Convert.ToInt32(reader.ReadLine());

for (int i = 0; i < count; i++)
{
okunan=reader.ReadLine();
string[] words = okunan.Split(' ');
Console.WriteLine(" substr1 : "+substr1(words[0],words[1]));
Console.WriteLine(" substr2 : " + substr2(words[0], words[1]));

}
}