示例#1
0
    {
      if (aFullPath.Length == 0) 
        return this;
      
      int p = aFullPath.IndexOf('/');
      if (p >= 0)
      {
        string lSubFolder = aFullPath.Substring(0,p);

        IFtpFolder lFolder = GetSubFolder(lSubFolder, aSession);

        if (lFolder != null)
        {
          aFullPath = aFullPath.Substring(p+1);
          return lFolder.DigForSubFolder(aFullPath, aSession);
        }  

        else
        {
          return null;
        }
      }
      else 
      {
        return GetSubFolder(aFullPath, aSession);
      }
    }
    public void FindBaseFolderForFilename(string aPath, out IFtpFolder aFolder, out string aFilename, VirtualFtpSession aSession)
    {
示例#2
0
        public override IFtpFolder GetSubFolder(String folder, VirtualFtpSession session)
        {
            //if (!AllowBrowse(session))
            //    throw new FtpException(550, String.Format("Cannot access folder \"{0}\", permission to access items in this folder denied.", folder));

            IFtpFolder lFolder = SubFolderList[folder.ToLower()] as IFtpFolder;

            if (lFolder != null && !lFolder.AllowBrowse(session))
            {
                throw new FtpException(550, String.Format("Cannot access folder \"{0}\", permission to browse folder denied.", folder));
            }

            return(lFolder);
        }
示例#3
0
        public void FindBaseFolderForFilename(String path, out IFtpFolder folder, out String filename, VirtualFtpSession session)
        {
            if (path.IndexOf('/') != -1)
            {
                if (path.StartsWith("/"))
                {
                    folder = Root;
                    path   = path.Substring(1); /* remove / */
                }
                else
                {
                    folder = this;
                }

                Int32 lSeparatorIndex = path.IndexOf('/');
                while (lSeparatorIndex >= 0)
                {
                    String lFolderName = path.Substring(0, lSeparatorIndex);
                    folder = folder.GetSubFolder(lFolderName, session);

                    if (folder == null || !folder.AllowBrowse(session))
                    {
                        throw new FtpException(550, String.Format("Folder \"{0}\" does not exists, or access denied.", path));
                    }

                    path            = path.Substring(lSeparatorIndex + 1);
                    lSeparatorIndex = path.IndexOf('/');
                }
            }
            else
            {
                folder = this;
            }

            filename = path;
        }