Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
00133894
Commit
00133894
authored
6 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add FsUtils.CreateIncomingDirectories method
parent
4d623b5b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxCommon/FsUtils.cs
+37
-0
37 additions, 0 deletions
ATxCommon/FsUtils.cs
with
37 additions
and
0 deletions
ATxCommon/FsUtils.cs
+
37
−
0
View file @
00133894
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Globalization
;
using
System.IO
;
using
System.Linq
;
using
ATxCommon.Serializables
;
using
NLog
;
namespace
ATxCommon
...
...
@@ -228,6 +229,42 @@ namespace ATxCommon
return
retval
;
}
/// <summary>
/// Helper to create directories for all users that have a dir in the local
/// user directory (C:\Users) AND in the DestinationDirectory.
/// </summary>
/// <param name="dest">The full path to the destination directory, as given in
/// <see cref="ServiceConfig.DestinationDirectory"/>.</param>
/// <param name="tmp">The (relative) path to the temporary transfer location, as given in
/// <see cref="ServiceConfig.TmpTransferDir"/>, commonly a single folder name.</param>
/// <param name="incoming">The full path to the incoming directory, as given in
/// <see cref="ServiceConfig.IncomingPath"/>.</param>
/// <returns>The DateTime.Now object upon success, exceptions propagated otherwise.</returns>
public
static
DateTime
CreateIncomingDirectories
(
string
dest
,
string
tmp
,
string
incoming
)
{
var
localUserDirs
=
new
DirectoryInfo
(
@"C:\Users"
)
.
GetDirectories
()
.
Select
(
d
=>
d
.
Name
)
.
ToArray
();
var
remoteUserDirs
=
new
DirectoryInfo
(
dest
)
.
GetDirectories
()
.
Select
(
d
=>
d
.
Name
)
.
ToArray
();
foreach
(
var
userDir
in
localUserDirs
)
{
// don't create an incoming directory for the same name as the
// temporary transfer location:
if
(
userDir
==
tmp
)
continue
;
// don't create a directory if it doesn't exist on the target:
if
(!
remoteUserDirs
.
Contains
(
userDir
))
continue
;
CreateNewDirectory
(
Path
.
Combine
(
incoming
,
userDir
),
false
);
}
return
DateTime
.
Now
;
}
/// <summary>
/// Move all subdirectories of a given path into a destination directory. The destination
/// will be created if it doesn't exist yet. If a subdirectory of the same name already
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment