Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: Invalid Argument in For Loop Pin
computerpublic3-Mar-14 3:52
computerpublic3-Mar-14 3:52 
GeneralRe: Invalid Argument in For Loop Pin
OriginalGriff3-Mar-14 4:30
mveOriginalGriff3-Mar-14 4:30 
AnswerRe: Invalid Argument in For Loop Pin
Richard MacCutchan2-Mar-14 22:54
mveRichard MacCutchan2-Mar-14 22:54 
GeneralRe: Invalid Argument in For Loop Pin
computerpublic3-Mar-14 3:53
computerpublic3-Mar-14 3:53 
GeneralRe: Invalid Argument in For Loop Pin
Richard MacCutchan3-Mar-14 4:11
mveRichard MacCutchan3-Mar-14 4:11 
GeneralRe: Invalid Argument in For Loop Pin
computerpublic3-Mar-14 4:16
computerpublic3-Mar-14 4:16 
GeneralRe: Invalid Argument in For Loop Pin
Richard MacCutchan3-Mar-14 4:22
mveRichard MacCutchan3-Mar-14 4:22 
GeneralRe: Invalid Argument in For Loop Pin
computerpublic3-Mar-14 7:39
computerpublic3-Mar-14 7:39 
C#
<pre>/*No more errors. My input to the program is letter "e" which is enclosed within a text file in c:\\folder9. The decimal equivalent of letter "e" is 101. When I run 101 thru the BitArray, it evaluates all bits as false which is NOT CORRECT.*/
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Applica
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryInfo da = new DirectoryInfo("C:\\Folder9");
            FileInfo[] Arr = da.GetFiles();
            if (Arr.Length == 0)
            {
                throw new InvalidOperationException("No files found.");
            }
            // No need to loop through the array just to get the last item:
            FileInfo ap = Arr[Arr.Length - 1];
            long Totbyte = ap.Length;
            string filePath = ap.FullName;
            Console.WriteLine("Total Bytes = {0} bytes", Totbyte);
            // GetTempFileName *creates* the file, so it always exists:
            string temPath = Path.GetTempFileName();
            byte[] data = File.ReadAllBytes(filePath);
            File.WriteAllBytes(temPath, data);            
            
            byte[] dataB = new byte[1];
            BitArray bits = new BitArray(dataB);
            Console.WriteLine("length= {0}",bits.Length);
            for (long counter = 0; counter < Totbyte; counter++)
            {
                dataB[0] = data[counter];
                Console.WriteLine("{0}", dataB[0]);
                for (int count = 0; count < bits.Length; count++)
                {
                    if (bits[count] == true)
                        Console.WriteLine("{0}", bits[count]);
                    if (bits[count] == false)
                        Console.WriteLine("{0}", bits[count]);
                }
            }
        }
    }
}



GeneralRe: Invalid Argument in For Loop Pin
Richard MacCutchan3-Mar-14 21:59
mveRichard MacCutchan3-Mar-14 21:59 
GeneralRe: Invalid Argument in For Loop Pin
computerpublic4-Mar-14 3:55
computerpublic4-Mar-14 3:55 
GeneralRe: Invalid Argument in For Loop Pin
Richard MacCutchan4-Mar-14 5:25
mveRichard MacCutchan4-Mar-14 5:25 
Generalapplication icons??? Pin
Member 106142622-Mar-14 1:56
Member 106142622-Mar-14 1:56 
GeneralRe: application icons??? Pin
Pete O'Hanlon2-Mar-14 2:08
mvePete O'Hanlon2-Mar-14 2:08 
JokeRe: application icons??? Pin
dan!sh 2-Mar-14 23:45
professional dan!sh 2-Mar-14 23:45 
GeneralRe: application icons??? Pin
Ravi Bhavnani2-Mar-14 5:57
professionalRavi Bhavnani2-Mar-14 5:57 
GeneralRe: application icons??? Pin
Bernhard Hiller2-Mar-14 23:52
Bernhard Hiller2-Mar-14 23:52 
QuestionHow i can redirect URLs entered in the browser with C#? Pin
Amin Soltani1-Mar-14 22:56
Amin Soltani1-Mar-14 22:56 
AnswerRe: How i can redirect URLs entered in the browser with C#? Pin
OriginalGriff1-Mar-14 23:36
mveOriginalGriff1-Mar-14 23:36 
JokeRe: How i can redirect URLs entered in the browser with C#? Pin
Richard Andrew x643-Mar-14 9:44
professionalRichard Andrew x643-Mar-14 9:44 
AnswerRe: How i can redirect URLs entered in the browser with C#? Pin
Ravi Bhavnani2-Mar-14 5:59
professionalRavi Bhavnani2-Mar-14 5:59 
AnswerRe: How i can redirect URLs entered in the browser with C#? Pin
Eddy Vluggen2-Mar-14 7:19
professionalEddy Vluggen2-Mar-14 7:19 
AnswerRe: How i can redirect URLs entered in the browser with C#? Pin
Eddy Vluggen2-Mar-14 7:23
professionalEddy Vluggen2-Mar-14 7:23 
Questionfacial expression recognition Pin
Member 95388301-Mar-14 12:31
Member 95388301-Mar-14 12:31 
AnswerRe: facial expression recognition Pin
Richard MacCutchan1-Mar-14 21:05
mveRichard MacCutchan1-Mar-14 21:05 
AnswerRe: facial expression recognition Pin
Eddy Vluggen2-Mar-14 7:30
professionalEddy Vluggen2-Mar-14 7:30 

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

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