Posted on June 24, 2008 by Garbage Collector
Console Application
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace pr11
{
class Program
{
static void Main(string[] args)
{
FileInfo f = new FileInfo(@”C:\Documents and Settings\admin\Desktop\SD\file2.txt”);
[...]
Filed under: IO | Tagged: files, StreamReader, StreamWriter, Txt Files | Leave a Comment »
Posted on June 23, 2008 by Garbage Collector
With the FileInfo class, you can create new files, access information about the files, delete, and move files. This class also provides methods for opening, reading from, and writing to a file.
Console Application
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace pr5
{
class Program
{
static [...]
Filed under: IO | Tagged: create, FileInfo, files, IO | Leave a Comment »
Posted on June 23, 2008 by Garbage Collector
Console Application
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace pr4
{
class Program
{
static void Main(string[] args)
{
DirectoryInfo dir = new DirectoryInfo(@”C:\Documents and Settings\admin\Desktop\SD\”);
try
{
dir.CreateSubdirectory(“Projects”);
dir.CreateSubdirectory(@”Projects\Files”);
}
catch (IOException e)
{
Console.WriteLine(e.Message);
}
}
}
}
Filed under: IO | Tagged: IO, subdirectories | Leave a Comment »
Posted on June 23, 2008 by Garbage Collector
Console Application
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace pr3
{
class Program
{
static void Main(string[] args)
{
DirectoryInfo dir = new DirectoryInfo(@”C:\Documents and Settings\admin\Desktop\poze”);
FileInfo[] jpgfiles = dir.GetFiles(“*.jpg”);
Console.WriteLine(“Total number of jpg files {0}”, jpgfiles.Length);
foreach(FileInfo f in jpgfiles)
{
Console.WriteLine(“——————————————-”);
Console.WriteLine(“Name is : {0}”, f.Name);
Console.WriteLine(“Length of the file is : {0}”, f.Length);
Console.WriteLine(“Creation time is : {0}”, f.CreationTime);
Console.WriteLine(“Attributes of the file are : {0}”,f.Attributes.ToString());
}
Console.ReadLine();
}
}
}
Filed under: IO | Tagged: code, directory, files, IO | Leave a Comment »