Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FileClass
- GetContentFromFile(string path).
- File.exists(string path)
- public class FileClass
- {
- public string GetContentFromFile(string path)
- {
- if (File.exists(path))
- {
- //Do some more logic in here...
- }
- }
- }
- public interface IFileWrapper {
- bool Exists(string path);
- }
- public class FileWrapper : IFileWrapper {
- public bool Exists(string path) {
- return File.Exists(path);
- }
- }
- public class FileClass {
- private readonly IFileWrapper wrapper;
- public FileClass(IFileWrapper wrapper) {
- this.wrapper = wrapper;
- }
- public string GetContentFromFile(string path){
- if (wrapper.FileExists(path)) {
- //Do some more logic in here...
- }
- }
- }
Add Comment
Please, Sign In to add comment