aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2020-03-25 14:36:51 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2020-03-25 14:36:51 +0200
commit9f2461055ef42054026aab2da4e0363e57b67f2a (patch)
tree832f11418060c27211ca22157ecd4a4a0e573317 /Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
parent0826ff68565e476c5990945ed0cf8dacb2feee5b (diff)
parente3f44f81af2cc5a650041d06fe2106937af03560 (diff)
downloadTango-9f2461055ef42054026aab2da4e0363e57b67f2a.tar.gz
Tango-9f2461055ef42054026aab2da4e0363e57b67f2a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs')
-rw-r--r--Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs44
1 files changed, 34 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
index c18df97c9..46ca080a2 100644
--- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
+++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs
@@ -73,15 +73,18 @@ namespace Tango.FileSystem
});
}
- foreach (var file in Directory.GetFiles(request.Path))
+ if (!request.FoldersOnly)
{
- items.Add(new FileSystemItemDTO()
+ foreach (var file in Directory.GetFiles(request.Path, request.Filter != null ? request.Filter : "*.*"))
{
- Path = file,
- Type = FileSystemItemType.File,
- DateModified = File.GetLastWriteTimeUtc(file),
- Size = new FileInfo(file).Length
- });
+ items.Add(new FileSystemItemDTO()
+ {
+ Path = file,
+ Type = FileSystemItemType.File,
+ DateModified = File.GetLastWriteTimeUtc(file),
+ Size = new FileInfo(file).Length
+ });
+ }
}
return new FileSystemItemDTO()
@@ -92,24 +95,28 @@ namespace Tango.FileSystem
};
}
- public Task<FileSystemItem> GetFolder(String path)
+ public Task<FileSystemItem> GetFolder(String path, bool foldersOnly = false, String filter = "*.*")
{
return Task.Factory.StartNew<FileSystemItem>(() =>
{
return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest()
{
Path = path,
+ FoldersOnly = foldersOnly,
+ Filter = filter,
}));
});
}
- public Task<FileSystemItem> GetFolder(Environment.SpecialFolder specialFolder)
+ public Task<FileSystemItem> GetFolder(Environment.SpecialFolder specialFolder, bool foldersOnly = false, String filter = "*.*")
{
return Task.Factory.StartNew<FileSystemItem>(() =>
{
return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest()
{
- SpecialFolder = specialFolder
+ SpecialFolder = specialFolder,
+ FoldersOnly = foldersOnly,
+ Filter = filter,
}));
});
}
@@ -174,5 +181,22 @@ namespace Tango.FileSystem
throw new FileNotFoundException("Could not locate the source file or folder.");
}
}
+
+ public FileSystemItemDTO CreateFolder(String path, String folderName)
+ {
+ String fullPath = Path.Combine(path, folderName);
+
+ if (Directory.Exists(fullPath))
+ {
+ throw new IOException("The specified directory name already exists.");
+ }
+
+ Directory.CreateDirectory(fullPath);
+
+ return GetFolder(new GetFileSystemItemRequest()
+ {
+ Path = fullPath
+ });
+ }
}
}