30 Eylül 2009 Çarşamba

Get File Names with C#

You can use the following code, if you want to get file names in a directory using C#:

using System;
using System.IO;

class Program
{
static void Main()
{
string[] array1 = Directory.GetFiles(@"C:\");

// Put all txt files in root directory into array2.
string[] array2 = Directory.GetFiles(@"C:\", "*.txt");

Console.WriteLine("Files:");
foreach (string name in array1)
{
Console.WriteLine(name);
}

// Display all txt files.
Console.WriteLine("txt Files:");
foreach (string name in array2)
{
Console.WriteLine(name);
}
}
}

Running C# on Command Prompt


If you have trouble setting up Microsoft Visual Studio, you can still compile and run C# code. You can download and install Microsoft Visual C++ Express Edition and run its command prompt to compile and run your .cs files.
To write your .cs files, you can use any text editor such as Notepad++ or PsPad. Let's examine an example: Open a text editor and paste the following code:

using System;
class Hello {
public static void Main () {
Console.WriteLine ("Hello World");
}
}


Save the file as hello.cs.

To use command prompt, go to Start -> All Programs -> Microsoft Visual C++ Express Edition -> Visual Studio Tools -> Visual Studio Command Prompt 

Go to the necessary directory and type csc hello.cs to compile. 

If compilation was successful, hello.exe is created in that directory. You can run it by typing hello to the command prompt. 

That's it.
Good programming!

7 Eylül 2009 Pazartesi

Youtube: An error occurred, please try again later


Youtube'da video izlemek isterken, bu hatayı alıyorsanız, aşağıda belirtilenleri uygulamanız probleminizi çözecek:

Windows kullanıcıları için: Yerel ağ bağlantısı -> Özellikler -> TCP-IP > DNS ata > Üst kısma 208.67.222.222 / Alt kısma 208.67.222.220 (Kablosuz ağ kullananlar çözüm için yazının yorumlarına bakabilir.)

MacOS kullanıcıları için: System Preferences -> Network -> Advanced -> DNS -> artı işaretine basarak yeni adres ekliyoruz: 208.67.222.222 -> Apply ve OK

Artık Youtube videolarını izleyebilirsiniz.