Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 4:59
mveOriginalGriff31-Mar-15 4:59 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 5:03
Member 1157009831-Mar-15 5:03 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 5:10
mveOriginalGriff31-Mar-15 5:10 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 6:23
Member 1157009831-Mar-15 6:23 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 6:36
mveOriginalGriff31-Mar-15 6:36 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 6:48
Member 1157009831-Mar-15 6:48 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 7:15
Member 1157009831-Mar-15 7:15 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 8:10
mveOriginalGriff31-Mar-15 8:10 
Forget that way to do it - you don't need it (if your numbers are all on separate lines) and it's a bit advanced for what you have been asked to do.

There are a large number of ways to do this within the spirit and (mostly) the letter of what you professor asked.
The first is probably cheating, but it very, very simple:
Read each line from the fle, convert the number to an integer (which you need to do in order to compare them, string comparisons are different) and write each number to a separate file in a new empty folder:
C#
File.WriteAllText(@"D:\Temp\AF\" + i.ToString("0000") + ".txt", i.ToString());
That will create each value as a separate file, called the number it contains (padded to 4 digits with zeros).
Then when you read the files list, Windows will sort it for you...Laugh | :laugh:
Probably cheating, as I said...

The next is to use Seek to treat a file as a block of memory.
If you read your input file line by line, and write it to a new file using ToString("0000") you will end up with a file containing equally spaced values - each one occupies 4 bytes. So if you use Stream.Seek, you can treat the file as an array, and write a quick Bubble sort method to sort the values within that file. You can then read the file, and generate your sorted.txt file from that.

The options tend to get a bit more complex from there on!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 8:28
Member 1157009831-Mar-15 8:28 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 8:45
mveOriginalGriff31-Mar-15 8:45 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 15:27
Member 1157009831-Mar-15 15:27 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff31-Mar-15 22:00
mveOriginalGriff31-Mar-15 22:00 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 115700981-Apr-15 6:17
Member 115700981-Apr-15 6:17 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
OriginalGriff1-Apr-15 6:59
mveOriginalGriff1-Apr-15 6:59 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 115700981-Apr-15 9:24
Member 115700981-Apr-15 9:24 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 115700981-Apr-15 11:54
Member 115700981-Apr-15 11:54 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 6:26
Member 1157009831-Mar-15 6:26 
GeneralRe: trying to search a text file for a certain string and display it in a richTextBox Pin
Member 1157009831-Mar-15 5:01
Member 1157009831-Mar-15 5:01 
QuestionSplit list to two gridview columns in C# winforms Pin
arsale31-Mar-15 3:27
arsale31-Mar-15 3:27 
AnswerRe: Split list to two gridview columns Pin
Eddy Vluggen31-Mar-15 7:31
professionalEddy Vluggen31-Mar-15 7:31 
GeneralRe: Split list to two gridview columns Pin
arsale31-Mar-15 10:46
arsale31-Mar-15 10:46 
GeneralRe: Split list to two gridview columns Pin
Eddy Vluggen31-Mar-15 13:03
professionalEddy Vluggen31-Mar-15 13:03 
GeneralRe: Split list to two gridview columns Pin
arsale31-Mar-15 23:20
arsale31-Mar-15 23:20 
GeneralRe: Split list to two gridview columns Pin
Eddy Vluggen31-Mar-15 23:41
professionalEddy Vluggen31-Mar-15 23:41 
GeneralRe: Split list to two gridview columns Pin
arsale31-Mar-15 23:58
arsale31-Mar-15 23:58 

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.