-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileLoader.cs
More file actions
42 lines (39 loc) · 1.01 KB
/
FileLoader.cs
File metadata and controls
42 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
namespace _2_interfejsy_kolekcje
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class FileLoader
{
private string[] _loadedWords;
public List<string> LoadStringCollectionFromFile(string path)
{
List<string> wordList = new List<string>();
LoadFile(path);
wordList = _loadedWords.ToList();
return wordList;
}
/// <summary>
///
/// </summary>
/// <param name="path"></param>
private bool LoadFile(string path)
{
try
{
_loadedWords = File.ReadAllLines(path);
return _loadedWords.Any();
}
catch(FileNotFoundException ex)
{
//logs
return false;
}
catch(Exception ex)
{
return false;
}
}
}
}