}, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.Rnfr, RnfrCommand, args.Length gt; 0? args [0]:null);
}
override void RntoCommandHandler (string parameters)
{[] args=parameters.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.Rnto, RntoCommand, args.Length gt; 0? args [0]:null);
}
override void SizeCommandHandler (string parameters)
{[] args=parameters.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.Size, SizeCommand, args.Length gt; 0? args [0]:null);
}
override void StorCommandHandler (string parameters)
{[] args=parameters.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.Stor, StorCommand, args.Length gt; 0? args [0]:null);
}
override void StouCommandHandler (string parameters)
{[] args=parameters.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.Stou, StouCommand, args.Length gt; 0? args [0]:string.Empty);
}
override void UserCommandHandler (string parameters)
{[] args=parameters.Split (new [] { }, StringSplitOptions.RemoveEmptyEntries); (FtpCommand.User, UserCommand, args.Length gt; 0? args [0]:null);
}
# endregion
# endregion
# endregion
}
Лістинг класу FileSystemWorker.cs
public class FileSystemWorker
{readonly string _rootDirectory;
UserRights _userRights; FileStream _savingFile; FileStream _readingFile; const int BufferSize=1048576;// 1MBFileSystemWorker (string rootDirectory)
{(! Directory.Exists (rootDirectory)) new DirectoryNotFoundException (rootDirectory);
_ rootDirectory=Path.GetFullPath (rootDirectory) ;. SetCurrentDirectory (_rootDirectory);
}
void InitUserRights (UserRights userRights)
{
_ userRights=userRights;
}
void GoToParentDirectory ()
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
currentPath=CheckAndGetCurrentDirectory (); (string.Compare (_rootDirectory, currentPath, StringComparison.OrdinalIgnoreCase)!=0) .SetCurrentDirectory (Directory.GetParent (currentPath) .FullName);
}
void GoToRootDirectory ()
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
. SetCurrentDirectory (_rootDirectory);
}
void ChangeDirecroty (string directory)
{(! _ userRights.CanDownload ()) new FileSystemAccessDeniedException ();
newPath=Path.Combine (CheckAndGetCurrentDirectory (), directory.TrimStart (new [] { laquo ;, /})); (! Directory.Exists (newPath)) new FileSystemAccessDeniedException ();
. SetCurrentDirectory (newPath);
}
string CreateDirectory (string directory)
{(! _ userRights.CanCreate ()) new FileSystemAccessDeniedException ();
path=Path.Combine (CheckAndGetCurrentDirectory (), directory.TrimStart (new [] { laquo ;, /}));
(Directory.Exists (path)) new FileSystemException (string.Format ( Directory " {0} " already exists raquo ;, directory));
{. CreateDirectory (path);
} (IOException ex)
{new FileSystemException (ex.Message.Replace (_rootDirectory, ));
} path.Replace (_rootDirectory, );
}
void RemoveDirectory (string directory)
{(! _ userRights.CanCreate ()) new FileSystemAccessDeniedException ();
path=Path.Combine (CheckAndGetCurrentDirectory (), directory.TrimStart (new [] { laquo ;, /}));
{. Delete (path);
} (IOException)
{new FileSystemAccessDeniedException ();
}
}
string GetCurrentDirectory ()
{path=CheckAndGetCurrentDirectory (). Replace (_rootDirectory, ); Path.IsPathRooted (pa...