public void CreateDoc(string nameOfProduct) { Product a = repo.Find(nameOfProduct); string path = @"c:\bazy\"; path += a.NameOfProduct + ".txt"; if (!File.Exists(path)) { using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(a.ToString()); } } }