private void StartServer() { string lDiskFolder = Path.GetDirectoryName(typeof(MainForm).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 = port; fFtpServer.Timeout = 60 * 1000; /* 1 minute */ if (this.fFtpServer.BindingV4 != null) { this.fFtpServer.BindingV4.ListenerThreadCount = 10; } fFtpServer.RootFolder = fRootFolder; fFtpServer.UserManager = fUserManager; fFtpServer.ServerName = "VirtualFTP Sample - powered by RemObjects Internet Pack for .NET"; fFtpServer.Open(); addToLog("VirtualFTP 0.3 BETA - started up"); }
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); }
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); }
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); }