Results 1 to 2 of 2

Thread: File Handling in C#

  1. #1
    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 ) ;
    }
    }


    Output:

    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

  2. #2
    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.

Similar Threads

  1. What is File Handling in Visual Basic 6.0?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 27-12-2010, 05:54 AM
  2. Photoshop, file formats and handling in the memory
    By NathanDS in forum Windows Software
    Replies: 4
    Last Post: 25-09-2010, 12:03 PM
  3. Is File handling in Java Swing possible
    By Vivan in forum Software Development
    Replies: 5
    Last Post: 20-07-2010, 11:51 PM
  4. Handling basic text file using Perl
    By Amie in forum Software Development
    Replies: 3
    Last Post: 06-11-2009, 11:37 PM
  5. perl file handling question
    By Arlo in forum Software Development
    Replies: 3
    Last Post: 18-06-2009, 09:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,869,844.81831 seconds with 17 queries