FILE HANDLING
STREAM
STREAM IS A CONCEPT BY WHICH WE CAN CONNECT DIFFERENT DEVICES LIKE CONSOLE,HDD,PENDRIVE ETC AND ALSO USE READ AND WRITE OPERATIONS.  
TYPES OF STREAM
- FILE ORIENTED STREAM.
 - CHARACTER ORIENTED STREAM.
 
EXAMPLE OF FILE STREAM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace FileHandling
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void copyingfi_Click(object sender, EventArgs e)
        {
            FileStream source = new FileStream("C:\\sachin.ini", FileMode.Open);
            FileStream destination = new FileStream("D:\\sachin.ini", FileMode.Create);
            source.CopyTo(destination);
            while (true)
            {
                int i = source.ReadByte();
                if (i == -1)
                {
                    break;
                    destination.WriteByte(Convert.ToByte(i));
                }
                destination.Close();
            }
        }
    }
}
No comments:
Post a Comment