Click here to Skip to main content
11,584,622 members (65,700 online)
   

C#

 
Questionsingle log file for two classes. Pin
vanikanc11-Jan-13 10:27
membervanikanc11-Jan-13 10:27 
AnswerRe: single log file for two classes. Pin
mark merrens11-Jan-13 10:58
membermark merrens11-Jan-13 10:58 
GeneralRe: single log file for two classes. Pin
Garth J Lancaster11-Jan-13 12:56
memberGarth J Lancaster11-Jan-13 12:56 
GeneralRe: single log file for two classes. Pin
vanikanc14-Jan-13 3:00
membervanikanc14-Jan-13 3:00 
AnswerRe: single log file for two classes. Pin
PIEBALDconsult11-Jan-13 13:26
memberPIEBALDconsult11-Jan-13 13:26 
GeneralRe: single log file for two classes. Pin
vanikanc15-Jan-13 2:24
membervanikanc15-Jan-13 2:24 
GeneralRe: single log file for two classes. Pin
PIEBALDconsult15-Jan-13 3:08
memberPIEBALDconsult15-Jan-13 3:08 
QuestionBinary File Library Pin
dxtrx11-Jan-13 10:24
memberdxtrx11-Jan-13 10: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 Pin
Garth J Lancaster11-Jan-13 11:18
memberGarth J Lancaster11-Jan-13 11:18 
GeneralRe: Binary File Library Pin
dxtrx11-Jan-13 11:41
memberdxtrx11-Jan-13 11:41 
GeneralRe: Binary File Library Pin
Garth J Lancaster11-Jan-13 12:43
memberGarth J Lancaster11-Jan-13 12:43 
GeneralRe: Binary File Library Pin
dxtrx11-Jan-13 12:47
memberdxtrx11-Jan-13 12:47 
QuestionLatency In Button Click When Using MVVM Pin
Tee12311-Jan-13 7:25
memberTee12311-Jan-13 7:25 
AnswerRe: Latency In Button Click When Using MVVM Pin
SledgeHammer0111-Jan-13 9:38
memberSledgeHammer0111-Jan-13 9:38 
GeneralRe: Latency In Button Click When Using MVVM Pin
Tee12311-Jan-13 10:14
memberTee12311-Jan-13 10:14 
QuestionC# computer name rename Pin
EvetsMostel11-Jan-13 7:00
memberEvetsMostel11-Jan-13 7:00 
AnswerRe: C# computer name rename Pin
jibesh11-Jan-13 7:47
memberjibesh11-Jan-13 7:47 
GeneralRe: C# computer name rename Pin
EvetsMostel11-Jan-13 7:54
memberEvetsMostel11-Jan-13 7:54 
GeneralRe: C# computer name rename Pin
EvetsMostel11-Jan-13 11:30
memberEvetsMostel11-Jan-13 11:30 
GeneralRe: C# computer name rename Pin
EvetsMostel14-Jan-13 13:15
memberEvetsMostel14-Jan-13 13:15 
QuestionFTP Decryption Error Pin
Member 865395910-Jan-13 18:22
memberMember 865395910-Jan-13 18:22 
AnswerRe: FTP Decryption Error Pin
Bernhard Hiller10-Jan-13 21:46
memberBernhard Hiller10-Jan-13 21:46 
GeneralRe: FTP Decryption Error Pin
Garth J Lancaster11-Jan-13 11:00
memberGarth J Lancaster11-Jan-13 11:00 
AnswerRe: FTP Decryption Error Pin
Eddy Vluggen11-Jan-13 2:28
mvpEddy Vluggen11-Jan-13 2:28 
GeneralRe: FTP Decryption Error Pin
Garth J Lancaster11-Jan-13 11:00
memberGarth J Lancaster11-Jan-13 11:00 

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
Web04 | 2.8.150707.1 | Last Updated 7 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid