Freind, This is the dish served to your plate:
public class CreateFileOrFolder
{
static void Main()
{
string activeDir = @"c:\testdir2";
string newPath = System.IO.Path.Combine(activeDir, "mySubDir");
System.IO.Directory.CreateDirectory(newPath);
string newFileName = System.IO.Path.GetRandomFileName();
newPath = System.IO.Path.Combine(newPath, newFileName);
if (!System.IO.File.Exists(newPath))
{
using (System.IO.FileStream fs = System.IO.File.Create(newPath))
{
for (byte i = 0; i < 100; i++)
{
fs.WriteByte(i);
}
}
}
try
{
byte[] readBuffer = System.IO.File.ReadAllBytes(newPath);
foreach (byte b in readBuffer)
{
Console.WriteLine(b);
}
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
}
System.Console.WriteLine("Press any key to exit.");
System.Console.ReadKey();
}
}
Thanks,
Ambesha