Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 10-11-2008
Join Date: Aug 2008
Posts: 46
File Handling in C#

The FileInfo classes are derived from the MarshaByRefObject class. This permits to transfer the objects of FileInfo class across applications.The FileSystemInfo & FileInfo classes are defined in System.IO namespace.

The first thing that we can do with files is find out the information about it. Consider the following program for finding out the information.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO ;

class Class1


static void Main(string[] args)

FileInfo f1 = new FileInfo (@"c:\file1.txt");
Console.WriteLine ( "File name is : " + f1.Name );
Console.WriteLine ( "In Folder : " + f1.Directory ) ;
Console.WriteLine ( "Full name is : " + f1.FullName ) ;
Console.WriteLine ( "Last Write Time : " + f1.LastWriteTime.ToString() ) ;
Console.WriteLine ("Length : " + f1.Length ) ;
Console.WriteLine ("Creation Time : " + f1.CreationTime ) ;
Console.WriteLine ("Last access Time : " + f1.LastAccessTime ) ;
Console.WriteLine ("Attributes : " + f1.Attributes ) ;


File name is : file1.txt
In Folder : c:\
Full name is : c:\file1.txt
Last Write Time : 10/2/2001 1:25:21 PM
Length : 12
Creation Time : 10/2/2001 1:25:09 PM
Last access Time : 10/2/2001 1:25:31 PM
Attributes : Archive
Reply With Quote
Old 10-11-2008
Join Date: Aug 2008
Posts: 53
Re: File Handling in C#

C# makes use of a thing called a stream. A stream is a link between your program and a file. Data can flow up or down your stream, so that streams can be used to read and write to files. The stream is the thing that links your program with the operating system of the computer you are using. The operating system actually does the work, and the C# system you are using will convert your request to use streams into instructions for the operating system you are using at the time:

There are a number of different streams which can be used to connect your program to a network file or a local disk. The important thing is that all the streams are used in the same way. This makes it easy to change the place where the stream writes to.
Reply With Quote

  TechArena Community > Software > Software Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "File Handling in C#"
Thread Thread Starter Forum Replies Last Post
What is File Handling in Visual Basic 6.0? Dėfrim Software Development 4 27-12-2010 05:54 AM
Photoshop, file formats and handling in the memory NathanDS Windows Software 4 25-09-2010 12:03 PM
Is File handling in Java Swing possible Vivan Software Development 5 20-07-2010 11:51 PM
Handling basic text file using Perl Amie Software Development 3 06-11-2009 11:37 PM
perl file handling question Arlo Software Development 3 18-06-2009 09:37 AM

All times are GMT +5.5. The time now is 01:56 PM.