Rich Newman

ColonDelimitedMovieFinder Class – .Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MovieFinderTestSpring.Net
    public class ColonDelimitedMovieFinder : IMovieFinder
        #region IMovieFinder Members

        public List<Movie> FindAll()
            List<Movie> movieList = new List<Movie>();
            FileInfo file = new FileInfo(".\\Movies.txt");
            if (file.Exists)
                StreamReader streamReader = new StreamReader(file.FullName);
                        while (!streamReader.EndOfStream)
                            string line = streamReader.ReadLine();
                            //string[] movieData = line.Split(new char[] {':'});
                            string title = line.Remove(line.IndexOf(":"));
                            string director = line.Substring(line.IndexOf(":") + 1);
                            Movie movie = new Movie(title, director);
                    finally { streamReader.Close(); }
            return movieList;


Leave a Comment »

No comments yet.

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: