[Fixes] files sharing
This commit is contained in:
parent
0b38365cec
commit
27fe16ee0d
1 changed files with 11 additions and 7 deletions
|
|
@ -18,14 +18,18 @@ namespace Yavsc.ViewModels.UserFiles
|
||||||
private DirectoryInfo dInfo;
|
private DirectoryInfo dInfo;
|
||||||
public UserDirectoryInfo(string username, string path)
|
public UserDirectoryInfo(string username, string path)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(username))
|
||||||
|
throw new NotSupportedException("No user name, no user dir.");
|
||||||
UserName = username;
|
UserName = username;
|
||||||
var finalPath = (path==null) ? username : username + Path.DirectorySeparatorChar + path;
|
var finalPath = username;
|
||||||
if ( !finalPath.IsValidPath() )
|
if (!string.IsNullOrWhiteSpace(path))
|
||||||
|
finalPath += Path.DirectorySeparatorChar + path;
|
||||||
|
if (!finalPath.IsValidPath())
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"File name contains invalid chars, using path {finalPath}");
|
$"File name contains invalid chars, using path {finalPath}");
|
||||||
|
|
||||||
dInfo = new DirectoryInfo(
|
dInfo = new DirectoryInfo(
|
||||||
Path.Combine(Startup.UserFilesDirName,finalPath));
|
Startup.UserFilesDirName+Path.DirectorySeparatorChar+finalPath);
|
||||||
Files = dInfo.GetFiles().Select
|
Files = dInfo.GetFiles().Select
|
||||||
( entry => new DefaultFileInfo { Name = entry.Name, Size = entry.Length,
|
( entry => new DefaultFileInfo { Name = entry.Name, Size = entry.Length,
|
||||||
CreationTime = entry.CreationTime, LastModified = entry.LastWriteTime }).ToArray();
|
CreationTime = entry.CreationTime, LastModified = entry.LastWriteTime }).ToArray();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue