Example #1
0
    public static void StartServer()
    {
      string lDiskFolder = Path.GetDirectoryName(typeof(CmdMain).Assembly.Location)+@"\FtpRoot";;

      fRootFolder = new VirtualFolder(null, "[ROOT]");
      fRootFolder.Add(new VirtualFolder(null, "virtual"));
      fRootFolder.Add(new DiscFolder(null, "drive-c", @"c:\"));
      fRootFolder.Add(new DiscFolder(null, "disc", lDiskFolder));
      fRootFolder.Add(new EmptyFile(null, "=== Welcome to the FTP ==="));

      fUserManager = new UserManager();
      ((UserManager)fUserManager).AddUser("test", "test");

      fFtpServer = new VirtualFtpServer();
      fFtpServer.Port = 2222;
      fFtpServer.Timeout = 60*1000; /* 1 minute */
      fFtpServer.Binding.ListenerThreadCount = 10;
      fFtpServer.RootFolder = fRootFolder;
      fFtpServer.UserManager = fUserManager;
      fFtpServer.ServerName = "VirtualFTP Sample - powered by RemObjects Internet Pack for .NET";
      
      fFtpServer.Open();		

      Debug.Write("VirtualFTP 0.3 BETA - started up");
    }
Example #2
0
        public void Start()
        {
            rootFolder = new VirtualFolder(null, "root");
            SetReadOnly(rootFolder, "root");

            VirtualFtpServer fFtpServer = new VirtualFtpServer();
            fFtpServer.Detailed500Errors = true;
            fFtpServer.Port = port;
            fFtpServer.PassiveAddress = passiveAddress;
            fFtpServer.PassivePortFrom = passivePortFrom;
            fFtpServer.PassivePortTo = passivePortTo;
            fFtpServer.Timeout = 60 * 1000; /* 1 minute */
            if (fFtpServer.BindingV4 != null)
                fFtpServer.BindingV4.ListenerThreadCount = 10;
            fFtpServer.RootFolder = rootFolder;
            fFtpServer.UserManager = new UserManagerEx(fFtpServer, rootPath);
            fFtpServer.ServerName = "BitMobile FTP Server";
            fFtpServer.OnUserLogin += OnUserLogin;
            fFtpServer.OnChangeDirectory += OnChangeDirectory;

            fFtpServer.Open();
        }
Example #3
0
        private IFtpFolder CreateAdminFolder(VirtualFtpSession session)
        {
            String solutionName = session.Username.Split('_')[0];

            CreateFileSystemFoldersIfNotExists(solutionName);

            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            DiscFolder df;
            df = new DiscFolder(null, "exchange", GetExchangeFolder(solutionName));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            CatalogFile cfs = new CatalogFile(null, "exchange.txt", GetExchangeFolder(solutionName));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            df = new DiscFolder(null, "shared", GetSharedFolder(solutionName));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            cfs = new CatalogFile(null, "shared.txt", GetSharedFolder(solutionName));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            df = new DiscFolder(null, "private", GetPrivateFolder(solutionName, ""));
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            cfs = new CatalogFile(null, "private.txt", GetPrivateFolder(solutionName, ""));
            SetReadOnly(cfs, session.Username);
            f.Add(cfs);

            rootFolder.Add(f);
            return f;
        }
Example #4
0
        private IFtpFolder CreateUserFolder(VirtualFtpSession session)
        {
            String[] arr = session.Username.Split('_');
            String solutionName = arr[0];
            String userFolderName = arr[1];

            CreateFileSystemFoldersIfNotExists(solutionName);

            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            String sharedFolder = GetSharedFolder(solutionName);
            DiscFolder df;
            df = new DiscFolder(null, "shared", sharedFolder);
            SetReadOnly(df, session.Username);
            f.Add(df);

            CatalogFile cfs = new CatalogFile(null, "shared.txt", sharedFolder);
            SetReadOnly(cfs, session.Username); 
            f.Add(cfs);

            String privateFolder = GetPrivateFolder(solutionName, userFolderName);
            df = new DiscFolder(null, "private", privateFolder);
            SetReadOnly(df, session.Username);
            df.UserWrite = true;
            f.Add(df);

            CatalogFile cfp = new CatalogFile(null, "private.txt", privateFolder);
            SetReadOnly(cfp, session.Username);
            f.Add(cfp);

            rootFolder.Add(f);
            return f;
        }
Example #5
0
        private IFtpFolder CreateRootFolder(VirtualFtpSession session)
        {
            VirtualFolder f = new VirtualFolder(rootFolder, session.Username);
            SetReadOnly(f, session.Username);

            foreach (String dir in System.IO.Directory.EnumerateDirectories(rootPath))
            {
                String name = new System.IO.DirectoryInfo(dir).Name;
                DiscFolder df = new DiscFolder(null, name, dir);
                SetReadOnly(df, session.Username);
                f.Add(df);
            }
            rootFolder.Add(f);
            return f;
        }