Saturday, May 5, 2012

Binary file creation





using System;
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 WindowsFormsApplication1
{
    public partial class binaryfile : Form
    {
        public binaryfile()
        {
            InitializeComponent();
        }
        BinaryWriter bw;
        FileStream fs;
        BinaryReader br;
        private void button1_Click(object sender, EventArgs e)
        {
           
            fs = new FileStream(@"E:\demo.data", FileMode.Create);
            bw = new BinaryWriter(fs);
            for (int i = 0; i < 5; i++)
            {
                bw.Write(i);
               
            }
            bw.Close();
            MessageBox.Show("Binary file created successfully");

        }

        private void button2_Click(object sender, EventArgs e)
        {
            fs = new FileStream(@"E:\demo.data", FileMode.Open);
            br = new BinaryReader(fs);
            int l = (int)fs.Length;
            for (int i = 0; i < l / 4; i++)
            {
                listBox1.Items.Add(br.ReadInt32());
            }
        }
    }
}

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...