Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using WS.Models;
- namespace WS.DAO
- {
- public class UserDao
- {
- public static List<User> GetUsers()
- {
- var userList = new List<User>();
- //string path = "resources\\users.csv";
- //string pathFile = Path.Combine(
- //Path.GetDirectoryName(
- //Assembly.GetExecutingAssembly().Location), @path);
- //string pathFile = File.ReadLines()
- string text = File.ReadAllText("users.txt", Encoding.GetEncoding(1251));
- foreach (string row in text.Split('\n'))
- {
- if (!string.IsNullOrEmpty(row))
- {
- var cells = row.Split(',');
- User user = new User();
- user.lastName = cells[0];
- user.FirstNameAndPatronomic = cells[1];
- user.login = cells[2];
- user.password = cells[3];
- user.role = cells[4];
- user.photo = "Images\\" + user.login + ".jpg";
- userList.Add(user);
- }
- }
- return userList;
- }
- public static Image GetImageFromFile(string inputPath)
- {
- string path = Path.Combine(Path.GetDirectoryName(
- Assembly.GetExecutingAssembly().Location),
- @inputPath);
- Image image = new Bitmap(path);
- return image;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement