ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:16.84KB ,
资源ID:22574671      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22574671.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(FTP服务器源码Word文档格式.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

FTP服务器源码Word文档格式.docx

1、portPort on which to listen. public ls_FTP_Server(string ftpRootDir,string ip,int port) m_FtpRoot = ftpRootDir; m_pServer = new LumiSoft.Net.FTP.Server.FTP_Server(); this.m_pServer.CommandIdleTimeOut = 60000; this.m_pServer.LogCommands = false; this.m_pServer.MaxBadCommands = 30; this.m_pServer.Sess

2、ionIdleTimeOut = 800000; this.m_pServer.Port = port; this.m_pServer.IpAddress = ip; this.m_pServer.CreateDir += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnCreateDir); this.m_pServer.StoreFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnStoreFile); this.m_pServer.D

3、eleteDir += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDeleteDir); this.m_pServer.SysError += new LumiSoft.Net.ErrorEventHandler(this.OnSysError); this.m_pServer.DirExists += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDirExists); this.m_pServer.FileExists += new Lum

4、iSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnFileExists); this.m_pServer.RenameDirFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnRenameDirFile); this.m_pServer.DeleteFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDeleteFile); this.m_pServer.ValidateI

5、PAddress += new LumiSoft.Net.ValidateIPHandler(this.OnValidateIP); this.m_pServer.GetFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnGetFile); this.m_pServer.GetDirInfo += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnGetDirInfo); this.m_pServer.AuthUser += new Lumi

6、Soft.Net.FTP.Server.AuthUserEventHandler(this.OnAuthUser); m_pServer.Enabled = true; #region Events handling #region FTP server events #region method OnAuthUser public void OnValidateIP(object sender,ValidateIP_EventArgs e) e.Validated = true; #endregion public void OnAuthUser(object sender,AuthUser

7、_EventArgs e) if(Impersonate.LogonAndImpersonateUser(e.UserName,e.PasswData) e.Validated = true; else e.Validated = false; #region method OnGetDirInfo public void OnGetDirInfo(object sender,FileSysEntry_EventArgs e) try DataTable dt = e.DirInfo.TablesDirInfo; string physicalPath = GetPhysicalPath(e.

8、Name); / Add directories if(Directory.Exists(physicalPath) string dirs = Directory.GetDirectories(physicalPath); foreach(string d in dirs) DataRow dr = dt.NewRow(); drName = new DirectoryInfo(d).Name;Date = Directory.GetCreationTime(d); / drSize = IsDirectory = true; dt.Rows.Add(dr); / Add virtual f

9、olders if(File.Exists(physicalPath + _Config_ftp.xml) try DataSet ds = new DataSet(); ds.ReadXml(physicalPath + ); foreach(DataRow dr in ds.TablesvirtualFolder.Rows) / ToDo: if virtual folder is same name as physical folder / Add vitual folder to list only if it exists string vDirPhysicalPath = drpa

10、th.ToString(); if(Directory.Exists(vDirPhysicalPath) DataRow drX = dt.NewRow(); drX = drname = Directory.GetCreationTime(vDirPhysicalPath); / drX dt.Rows.Add(drX); catch / Add files string files = Directory.GetFiles(physicalPath); foreach(string f in files) / Hide config file if(Path.GetFileName(f).

11、ToLower() != _config_ftp.xml) DataRow dr = dt.NewRow(); dr = Path.GetFileName(f); = File.GetCreationTime(f); = new FileInfo(f).Length; = false; dt.Rows.Add(dr); catch #region method OnDirExists public void OnDirExists(object sender,FileSysEntry_EventArgs e) if(!Directory.Exists(GetPhysicalPath(e.Nam

12、e) #region method OnCreateDir public void OnCreateDir(object sender,FileSysEntry_EventArgs e) if(Directory.Exists(GetPhysicalPath(e.Name) Directory.CreateDirectory(GetPhysicalPath(e.Name); #region method OnDeleteDir public void OnDeleteDir(object sender,FileSysEntry_EventArgs e) IsVirtualDir(e.Name)

13、 & Directory.Exists(GetPhysicalPath(e.Name) Directory.Delete(GetPhysicalPath(e.Name); else #region method OnRenameDirFile public void OnRenameDirFile(object sender,FileSysEntry_EventArgs e) / Remove last / string to = e.NewName.Substring(0,e.NewName.Length - 1); string from = e.Name.Substring(0,e.Na

14、me.Length - 1); if(IsVirtualDir(to) | IsVirtualDir(from) | Directory.Exists(GetPhysicalPath(to) | File.Exists(GetPhysicalPath(to) if(Directory.Exists(GetPhysicalPath(from) Directory.Move(GetPhysicalPath(from),GetPhysicalPath(to); else if(File.Exists(GetPhysicalPath(from) File.Move(GetPhysicalPath(fr

15、om),GetPhysicalPath(to); #region method OnFileExists public void OnFileExists(object sender,FileSysEntry_EventArgs e) try if(File.Exists(GetPhysicalPath(e.Name) e.Validated = true; #region method OnGetFile public void OnGetFile(object sender,FileSysEntry_EventArgs e) e.FileStream = File.OpenRead(Get

16、PhysicalPath(e.Name); #region method OnStoreFile public void OnStoreFile(object sender,FileSysEntry_EventArgs e) if(!File.Exists(GetPhysicalPath(e.Name) e.FileStream = File.Create(GetPhysicalPath(e.Name); #region method OnDeleteFile public void OnDeleteFile(object sender,FileSysEntry_EventArgs e) if

17、(File.Exists(GetPhysicalPath(e.Name) File.Delete(GetPhysicalPath(e.Name); #region method OnSysError public void OnSysError(object sender,Error_EventArgs e) Error.DumpError(e.Exception,e.StackTrace); #region method GetPhysicalPath / Gets physical path from absolute path (replaces virtual folders with

18、 real path)./returns private string GetPhysicalPath(string path) string pPath = m_FtpRoot + bool endsWithSep = false; if(path.StartsWith(/ path = path.Substring(1,path.Length - 1); if(path.EndsWith( path = path.Substring(0,path.Length - 1); endsWithSep = true; string pathParts = path.Split(/, foreac

19、h(string part in pathParts) if(part.Length 0) / This is physical directory if(Directory.Exists(pPath + part) pPath += part + else / See if virtual folder if(File.Exists(pPath + ) try DataSet ds = new DataSet(); ds.ReadXml(pPath + ds.Tables.DefaultView.RowFilter = name= + part + if(ds.Tables.DefaultV

20、iew.Count 0) pPath = ds.Tables.DefaultView0 if(!pPath.EndsWith( pPath += else pPath += part + catch else pPath += part + endsWithSep & pPath.EndsWith( pPath = pPath.Substring(0,pPath.Length - 1); return pPath; #region method IsVirtualDir / Gets if specified dir is virtual directory.dir private bool

21、IsVirtualDir(string dir) if(dir.StartsWith( dir = dir.Substring(1,dir.Length - 1); if(dir.EndsWith( dir = dir.Substring(0,dir.Length - 1); string pPath = /- Move dir up and get physical path string pathParts = dir.Split( if(pathParts.Length 1) / pPath = for(int i=0;i(pathParts.Length - 1);i+) pPath += pathPartsi + if(pPath.Length = 0) pPath = / else / pPath = GetPhysicalPath(pPath); /-Directory.Exists(pPath + pathPartspathParts.Length - 1) / See if virtual folder if(File.Exists(pPath +

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1