TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
solomon mwika
1.2k
210
7.9k
Reading a text file
Jan 26 2014 3:17 AM
am trying to read random words from a textfile . well have managed to read the words and display them in textblock problem is i only need to read words of certain
length only for example 5 to ten letters only
here is my code so far
private void Mywords()
{
var ResourceStream = Application.GetResourceStream(new Uri("TextFile1.txt", UriKind.Relative));
using (Stream Myfilestream = ResourceStream.Stream)
{
string s = "";
StreamReader myStreamReader = new StreamReader(Myfilestream);
s = myStreamReader.ReadToEnd();
s = s.Trim(); //tlbRandomWords.Text = s; // char[] delimiters = { '\n', '\r' };
string[] words = s.Split(); // int index = rand.Next(0,delimiters.Count());
if (s.Split().Length < 6)
{
tlbRandomWords.Text = words[rand.Next(words.Count())].ToUpper();
}
}
}
Reply
Answers (
7
)
Offline Winform Desktop App with English & Hindi Words
write image file save as longbinary