Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C#

Cant write to file(working on a class project) C#

I cant write to file, not sure how/where to set _filePath Here is my current code:

using System; using System.Collections.Generic; using System.IO;

namespace weatherHumidity { // Loading weather data

class Program
{
    private static Stream _filePath;

    static void Main(string[] args)
    {
        string currentDirectory = Directory.GetCurrentDirectory();
        DirectoryInfo directory = new DirectoryInfo(currentDirectory);
        string fileName = Path.Combine(directory.FullName, "WeatherData.csv");
        List<string[]> fileContents = ReadWeatherData(fileName);


    }
    // Reading weather Data
    public static string ReadFile(string fileName)
    {
        using (var reader = new StreamReader(fileName))
        {
            return reader.ReadToEnd();
        }
    }
    public static List<string[]> ReadWeatherData(string fileName)

    {
        List<string[]> weatherHumidity = new List<string[]>();
        using (var reader = new StreamReader(fileName))
        {
            string line = "";
            reader.ReadLine();
            Console.ReadLine();
            while ((line = reader.ReadLine()) != null)
            {
                WeatherHumidity weatherdata = new WeatherHumidity();
                string[] values = line.Split(',');
                weatherdata.Temps = values[8];
                weatherHumidity.Add(values);

            }
        }
            return weatherHumidity;
    }

    //Writng some information to a file

    public static void WriteToFile(string value)
    {
        using (StreamWriter writer = new StreamWriter(_filePath))
        {
            writer.Write(value);
        }
        Console.ReadLine();
    }
}

}

Thanks for any help.