Click here to Skip to main content
   

C#

 
AnswerRe: Int32rect not found PinmvpRichard MacCutchan12-Jan-13 1:07 
GeneralRe: Int32rect not found Pinmemberz3ngew13-Jan-13 7:12 
QuestionProblem With User Controls [modified] PinmemberMah boubeh11-Jan-13 19:58 
AnswerRe: Problem With User Controls PinmvpDave Kreskowiak11-Jan-13 20:00 
GeneralRe: Problem With User Controls PinmemberMah boubeh11-Jan-13 20:09 
AnswerRe: Problem With User Controls PinmvpOriginalGriff11-Jan-13 23:13 
Questionsingle log file for two classes. Pinmembervanikanc11-Jan-13 11:27 
AnswerRe: single log file for two classes. Pinmembermark merrens11-Jan-13 11:58 
GeneralRe: single log file for two classes. PinmemberGarth J Lancaster11-Jan-13 13:56 
GeneralRe: single log file for two classes. Pinmembervanikanc14-Jan-13 4:00 
AnswerRe: single log file for two classes. PinmemberPIEBALDconsult11-Jan-13 14:26 
GeneralRe: single log file for two classes. Pinmembervanikanc15-Jan-13 3:24 
GeneralRe: single log file for two classes. PinmemberPIEBALDconsult15-Jan-13 4:08 
QuestionBinary File Library Pinmemberdxtrx11-Jan-13 11:24 
Hello Everyone this is my first question I am posting!
I need help with a code

I need to count the same books I have added to a Binary File and show that number in the console but since I am new with these types of codes i am seeking for your help

This is the code i have Written to add the books to the file and I also have the code to read the files (if needed will post it) Now the problem is i don't know how to count the same book i have added multiple times and show it in Console. If anyone can help me i will appreciate it
If u need any explanation let me know and i will try to explain with my knowledge
Thanks in Advance

{
    class Class1
    {
        //method I am Using to Add Books to my Binary File
        internal void AddBooks()
        {
            string addBook = "";
            while (addBook != "No")
            {
                Console.WriteLine("========================================");
                Console.WriteLine("Write the Books Identifiing number u want to add");
                //book number i will need this to count the same books
                int bookNumber = int.Parse(Console.ReadLine());
 
                Console.WriteLine("Write Books Titttle");
                string bookTittle = Console.ReadLine();
 
                Console.WriteLine("Write th Authors Name");
                string authorName = Console.ReadLine();
 
                Console.WriteLine("Write the publishing company ");
                string pubCompany = Console.ReadLine();
 
                FileStream fsBooks = new FileStream("Books.bin", FileMode.Append, FileAccess.Write);
                BinaryWriter bwBooks = new BinaryWriter(fsBooks);
 
                bwBooks.Write(bookNumber);
                bwBooks.Write(FillBlanks(bookTittle, 30));
                bwBooks.Write(FillBlanks(bookTittle,25));
                bwBooks.Write(FillBlanks(pubCompany, 15));
                bwBooks.Flush();
                Console.WriteLine("==========================");
                Console.WriteLine("Do You Want to add another Book:  'Yes'/'No' ");
                addBook = Console.ReadLine();
                bwBooks.Close();
                fsBooks.Close();
            }
        }
        static string FillBlanks(string text, int size)
        {
            string blanks = "";
 
            if (text.Length < size)
            {
                int difference = size - text.Length;
                for (int i = 0; i < difference; i++)
                {
                    blanks += " ";
                }
            }
            else if (text.Length > size)
            {
                text = text.Substring(0, size);
            }
            return text + blanks;
        }
    }
}

AnswerRe: Binary File Library PinmemberGarth J Lancaster11-Jan-13 12:18 
GeneralRe: Binary File Library Pinmemberdxtrx11-Jan-13 12:41 
GeneralRe: Binary File Library PinmemberGarth J Lancaster11-Jan-13 13:43 
GeneralRe: Binary File Library Pinmemberdxtrx11-Jan-13 13:47 
QuestionLatency In Button Click When Using MVVM PinmemberTee12311-Jan-13 8:25 
AnswerRe: Latency In Button Click When Using MVVM PinmemberSledgeHammer0111-Jan-13 10:38 
GeneralRe: Latency In Button Click When Using MVVM PinmemberTee12311-Jan-13 11:14 
QuestionC# computer name rename PinmemberEvetsMostel11-Jan-13 8:00 
AnswerRe: C# computer name rename Pinmemberjibesh11-Jan-13 8:47 
GeneralRe: C# computer name rename [modified] PinmemberEvetsMostel11-Jan-13 8:54 
GeneralRe: C# computer name rename PinmemberEvetsMostel11-Jan-13 12:30 
GeneralRe: C# computer name rename PinmemberEvetsMostel14-Jan-13 14:15 
QuestionFTP Decryption Error PinmemberMember 865395910-Jan-13 19:22 
AnswerRe: FTP Decryption Error PinmemberBernhard Hiller10-Jan-13 22:46 
GeneralRe: FTP Decryption Error PinmemberGarth J Lancaster11-Jan-13 12:00 
AnswerRe: FTP Decryption Error PinmvpEddy Vluggen11-Jan-13 3:28 
GeneralRe: FTP Decryption Error PinmemberGarth J Lancaster11-Jan-13 12:00 
Questionhow to export a div to pdf Pinmembershineskollam10-Jan-13 19:17 
AnswerRe: how to export a div to pdf PinmvpRichard MacCutchan10-Jan-13 22:51 
QuestionRegarding implementation of Dependency Injection with C# PinmemberTridip Bhattacharjee10-Jan-13 3:06 
AnswerRe: Regarding implementation of Dependency Injection with C# PinprotectorPete O'Hanlon10-Jan-13 3:22 
AnswerRe: Regarding implementation of Dependency Injection with C# Pinmemberjschell10-Jan-13 15:03 
AnswerRe: Regarding implementation of Dependency Injection with C# PinmemberSledgeHammer0110-Jan-13 15:57 
GeneralRe: Regarding implementation of Dependency Injection with C# PinmemberTridip Bhattacharjee10-Jan-13 21:07 
GeneralRe: Regarding implementation of Dependency Injection with C# PinprotectorPete O'Hanlon10-Jan-13 22:11 
QuestionHow to draw an arc in winRT with animation? Pinmemberabinashokk9-Jan-13 22:55 
AnswerRe: How to draw an arc in winRT with animation? PinprotectorPete O'Hanlon9-Jan-13 23:34 
QuestionC#.NET 3.5 Code review checklist PinmemberMember 31370789-Jan-13 21:28 
AnswerRe: C#.NET 3.5 Code review checklist PinmvpEddy Vluggen9-Jan-13 23:54 
AnswerRe: C#.NET 3.5 Code review checklist Pinmemberdeflinek10-Jan-13 1:53 
AnswerRe: C#.NET 3.5 Code review checklist Pinmemberjschell10-Jan-13 15:06 
GeneralRe: C#.NET 3.5 Code review checklist PinmemberPIEBALDconsult10-Jan-13 16:16 
GeneralRe: C#.NET 3.5 Code review checklist PinmemberPIEBALDconsult10-Jan-13 15:46 
QuestionSocket programming Pinmembermohammadkaab9-Jan-13 4:32 
AnswerRe: Socket programming PinmvpDave Kreskowiak9-Jan-13 4:38 
GeneralRe: Socket programming Pinmembermohammadkaab9-Jan-13 8:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.150331.1 | Last Updated 1 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid