Click here to Skip to main content
15,884,473 members
Home / Discussions / C#
   

C#

 
GeneralRe: how can i make a double click event in c# with access Pin
Eddy Vluggen18-Mar-13 9:16
professionalEddy Vluggen18-Mar-13 9:16 
QuestionC# StreamReader Case sensitive Pin
Member 987302818-Mar-13 6:09
Member 987302818-Mar-13 6:09 
AnswerRe: C# StreamReader Case sensitive Pin
R. Giskard Reventlov18-Mar-13 6:41
R. Giskard Reventlov18-Mar-13 6:41 
GeneralRe: C# StreamReader Case sensitive Pin
Member 987302818-Mar-13 8:06
Member 987302818-Mar-13 8:06 
AnswerRe: C# StreamReader Case sensitive Pin
OriginalGriff18-Mar-13 6:41
mveOriginalGriff18-Mar-13 6:41 
GeneralRe: C# StreamReader Case sensitive Pin
Member 987302818-Mar-13 8:06
Member 987302818-Mar-13 8:06 
AnswerRe: C# StreamReader Case sensitive Pin
Richard Deeming18-Mar-13 8:56
mveRichard Deeming18-Mar-13 8:56 
AnswerRe: C# StreamReader Case sensitive Pin
Matt T Heffron18-Mar-13 9:25
professionalMatt T Heffron18-Mar-13 9:25 
First, the IndexOf()method has an overload that takes a StringComparison enumeration value, so you could just add the second parameter StringComparison.OrdinalIgnoreCase (or .CurrentCultureIgnoreCase or .InvariantCultureIgnoreCase, as appropriate).

However, this code is a bit strange...
Are you really writing the message to the same file you are scanning?
If not, it appears you are doing potentially a lot of extra work (e.g., reading the inbox(?) file multiple times).
How about something like this:
C#
if (!String.IsNullOrEmpty(CustodianEAddressText))
{
  List<string> list1 = new List<string>();
  using (StreamReader reader = new StreamReader(FileLocation))
  {
    string line1;
    while ((line1 = reader.ReadLine()) != null)
    {
      list1.Add(line1); // Add to list.
    }
  }
  for (AddressLength1 = 0; AddressLength1 < Length; AddressLength1++)
  {
    string cust1AddrLen1 = cust1[AddressLength1].ToString(); // only needs .ToString() if cust1 is not string[] or List<string>
    // If you don't need the LineArray1 populated this 1 line works:
    count1 = list1.Count(l => l.IndexOf(cust1AddrLen1, StringComparison.OrdinalIgnoreCase) != -1);
    // If you DO need LineArray1 to be populated with the matching lines, then these 2 lines work:
    string[] LineArray1 = (from line in list1
                           where line.IndexOf(cust1AddrLen1, StringComparison.OrdinalIgnoreCase) != -1
                           select line).ToArray();
    count1 = LineArray1.Length;

    string count1a = count1.ToString();   // I'm assuming you're using this somewhere you haven't shown... or else it isn't necessary

    using (StreamWriter filed = new StreamWriter(FileLocation, true)) // is this really the SAME FileLocation as above??
    {
      filed.WriteLine();
      filed.WriteLine("The email address {0} was found {1} times within the recipient's inbox", cust1AddrLen1, count1a);
    }
  }
}
else
{
  MessageBox.Show("Please Enter an Email Address");
}

QuestionHow to build an sms sending application in C# and Access Pin
Arif_Aqeel18-Mar-13 3:17
Arif_Aqeel18-Mar-13 3:17 
AnswerRe: How to build an sms sending application in C# and Access Pin
Marco Bertschi18-Mar-13 3:28
protectorMarco Bertschi18-Mar-13 3:28 
AnswerRe: How to build an sms sending application in C# and Access Pin
Vasudevan Deepak Kumar18-Mar-13 9:10
Vasudevan Deepak Kumar18-Mar-13 9:10 
Questioncode for genetic algorithm Pin
06b17-Mar-13 21:53
06b17-Mar-13 21:53 
AnswerRe: code for genetic algorithm Pin
Marco Bertschi17-Mar-13 23:55
protectorMarco Bertschi17-Mar-13 23:55 
GeneralRe: code for genetic algorithm Pin
Keith Barrow18-Mar-13 1:49
professionalKeith Barrow18-Mar-13 1:49 
AnswerRe: code for genetic algorithm Pin
Hari Om Prakash Sharma18-Mar-13 1:40
Hari Om Prakash Sharma18-Mar-13 1:40 
AnswerWhat Is the code of one hand clapping? Pin
Keith Barrow18-Mar-13 1:51
professionalKeith Barrow18-Mar-13 1:51 
GeneralRe: What Is the code of one hand clapping? Pin
Pete O'Hanlon18-Mar-13 1:54
mvePete O'Hanlon18-Mar-13 1:54 
GeneralRe: What Is the code of one hand clapping? Pin
Marco Bertschi18-Mar-13 3:26
protectorMarco Bertschi18-Mar-13 3:26 
SuggestionRe: code for genetic algorithm Pin
Steve4419-Mar-13 15:04
Steve4419-Mar-13 15:04 
QuestionRunning .exe in windows form but it opens an external window Pin
Sachin k Rajput 17-Mar-13 21:03
Sachin k Rajput 17-Mar-13 21:03 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Richard MacCutchan17-Mar-13 23:54
mveRichard MacCutchan17-Mar-13 23:54 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Eddy Vluggen18-Mar-13 1:32
professionalEddy Vluggen18-Mar-13 1:32 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Sachin k Rajput 18-Mar-13 3:29
Sachin k Rajput 18-Mar-13 3:29 
AnswerRe: Running .exe in windows form but it opens an external window Pin
Hari Om Prakash Sharma18-Mar-13 1:47
Hari Om Prakash Sharma18-Mar-13 1:47 
GeneralRe: Running .exe in windows form but it opens an external window Pin
Pete O'Hanlon18-Mar-13 1:55
mvePete O'Hanlon18-Mar-13 1:55 

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.