📄 ftpform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
namespace IsoFtp
{
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("IsoFtp.FTPForm")]
public partial class FTPForm : Form, IFtpZipIso
{
#region 实现接口
/// <summary>
/// 打开光驱托盘门
/// </summary>
public void OpenCdRomDoor()
{
}
/// <summary>
/// 关闭光驱托盘门
/// </summary>
public void CLoseCdRomDoor()
{
}
/// <summary>
/// 得到默认光驱名称
/// </summary>
public string GetDefaultCDRom()
{
return "";
}
/// <summary>
/// 大概实现一下
/// </summary>
public int ShowForm()
{
return 0;
}
public event EventHandler OnConvertCompleted;
#endregion
#region 取FTP字符属性
//ftp://username:password@192.168.0.1:21//
//ftp://sss//
/// <summary>
/// 用户名
/// </summary>
/// <param name="WCutString">字符串</param>
/// <returns></returns>
private string ftpUserName(string WCutString)
{
try
{
int bc = WCutString.IndexOf("//");
int ec = WCutString.IndexOf(":", 5);
int length = ec - bc;
string ftpun = WCutString.Substring(bc + 2, length - 2);
return (ftpun == "") ? "anonymous" : ftpun;
}
catch
{
return "anonymous";
}
}
/// <summary>
/// 密码
/// </summary>
/// <param name="WCutString">字符串</param>
/// <returns></returns>
private string ftpPassWord(string WCutString)
{
try
{
int bc = WCutString.IndexOf(":", 5);
int ec = WCutString.IndexOf("@");
int length = ec - bc;
string ftppw = WCutString.Substring(bc + 1, length - 1);
return (ftppw == "") ? "" : ftppw;
}
catch
{
return "";
}
}
/// <summary>
/// 主机
/// </summary>
/// <param name="WCutString">字符串</param>
/// <returns></returns>
private string ftpHost(string WCutString)
{
try
{
int bc = WCutString.IndexOf("@");
int ec = WCutString.IndexOf(":", WCutString.IndexOf(":", 5) + 1);
int length = ec - bc;
string wct = WCutString.Substring(bc + 1, length - 1);
if (wct.IndexOf("ftp") >= 0)
{
bc = WCutString.IndexOf("//");
ec = WCutString.IndexOf("/", bc + 2);
length = ec - bc;
wct = WCutString.Substring(bc + 2, length - 2);
}
return wct;
}
catch //ftp://sss//
{
int bc = WCutString.IndexOf("//");
int ec = WCutString.IndexOf("/", bc + 2);
int length = ec - bc;
return WCutString.Substring(bc + 2, length - 2);
}
}
/// <summary>
/// 端口
/// </summary>
/// <param name="WCutString">字符串</param>
/// <returns></returns>
private string ftpPort(string WCutString)
{
try
{
int bc = WCutString.IndexOf(":", WCutString.IndexOf(":", 5) + 1);
int ec = WCutString.IndexOf("/", WCutString.IndexOf("//") + 2);
int length = ec - bc;
string ftppt = WCutString.Substring(bc + 1, length - 1);
int portnum = 21;
if (!int.TryParse(ftppt, out portnum))
{
ftppt = "21";
}
return ftppt;
}
catch
{
return "21";
}
}
/// <summary>
/// 服务器路径
/// </summary>
/// <param name="WCutString">字符串</param>
/// <returns></returns>
private string ftpFilePath(string WCutString)
{
int ec = WCutString.IndexOf("/", WCutString.IndexOf("//") + 2);
return WCutString.Substring(ec);
}
#endregion
private string _DestFileStore = "";
private string _FileName = "";
private long _filesize = 0;
private int _Model = 0;
private string _ErrMsg = "";
private string _CdRomNum = "";
/// <summary>
/// 目标文件夹
/// </summary>
public string DestFilestore
{
get
{
return _DestFileStore;
}
set
{
if (!string.IsNullOrEmpty(value))
{
this.txtFTPPath.Text = value;
}
_DestFileStore = value;
}
}
/// <summary>
/// 文件名
/// </summary>
public string ResourceFileName
{
get { return _FileName; }
set
{
if (!string.IsNullOrEmpty(value))
{
lbfilename.Text = value;
}
_FileName = value;
}
}
/// <summary>
/// 文件尺寸
/// </summary>
public string Filesize { get { return _filesize.ToString(); } set { _filesize = long.Parse(value); } }
/// <summary>
/// 操作模式 0- 单个 1 - 批量制作ISO上传 2-只批量制作ISO 3-只批量上传
/// </summary>
public int OpterationModel
{
get
{
return _Model;
}
set
{
_Model = value;
}
}
/// <summary>
/// 光驱盘符
/// </summary>
public string CdRomNum { get { return _CdRomNum; } set { _CdRomNum = value; } }
/// <summary>
/// 错误信息
/// </summary>
public string ErrMessage { get { return _ErrMsg; } set { _ErrMsg = value; } }
public FTPForm()
{
InitializeComponent();
pg = this.progressBar1;
tb = txtLog;
tssl = toolStripStatusLabel1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -