Xkape Posted June 7, 2003 Posted June 7, 2003 Hello all, My example first... 13DU3T6=Tom in one folder and its equal is in another folder that looks like this below 13DU3T6=.txt What Function or statement would you use to have them compared and then populate a textbox with Tom.txt Any advise would be helpful, and thank in advance. J Quote
AndreRyan Posted June 7, 2003 Posted June 7, 2003 (edited) Do you want a character by character or line by line comparison? Edited June 7, 2003 by AndreRyan Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Xkape Posted June 7, 2003 Author Posted June 7, 2003 Which 1 would be better? I think character by character would be. Quote
aewarnick Posted June 7, 2003 Posted June 7, 2003 (edited) Do you want C# or VB? And char by char is an exact comparison which is probably what you want. What are you trying to do, exactly? Is it just a bool comparison? In other words, are you just determining if file1 is equal to file2 or not? Or do you want to extract all the sentences or lines that are different into the text box? I also suggest putting your language in your signature so that people know what syntax you want. Edited June 7, 2003 by aewarnick Quote C#
AndreRyan Posted June 7, 2003 Posted June 7, 2003 (edited) This code should do a char by char comparison Option Explicit On Option Strict On Public Class FileCompare 'Do a character by character comparison for file 1 Public Shared Function CompareCharByChar(ByVal File1 As String, ByVal File2 As String) As String Dim File1Stream As IO.StreamReader = New IO.StreamReader(File1) Dim File2Stream As IO.StreamReader = New IO.StreamReader(File2) Dim File1Data() As Char = File1Stream.ReadToEnd.ToCharArray Dim File2Data() As Char = File2Stream.ReadToEnd.ToCharArray File1Stream.Close() : File2Stream.Close() Dim Length As Int32, Result As String For Length = 1 To File1Data.GetUpperBound(0) If File1Data(Length).Equals(File2Data(Length)) Then Result &= File1Data(Length).ToString End If Next Return Result End Function End Class And I went to great pain to: public class FileCompare { //Do a character by character comparison for file 1 public string CompareCharByChar(string File1,string File2 ) { io.streamreader File1Stream = new io.StreamReader(File1); io.streamreader File2Stream = new IO.StreamReader(File2); char[] File1Data = File1Stream.ReadToEnd.ToCharArray; char[] File2Data = File2Stream.ReadToEnd.ToCharArray; File1Stream.Close(); File2Stream.Close(); Int32 Length; string Result; for (Length = 0; Length <= File1Data.GetUpperBound(0); Length++) If(File1Data(Length).Equals(File2Data(Length))=True); Result &= File1Data(Length).ToString; Return Result; } } Edited June 7, 2003 by AndreRyan Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.