首先这是一个winform项目。
1.using SharpSvn.Security;
using SharpSvn;运用一些using语句来进行第三方库的调用,一些库的调用,系统标准库
2.创建一个类,继承自FORM类,系统自动写好一些FORM的基本实现。不需要声明,直接在类的内部写各种函数进行实现。
3. //URL是URI的子集,统一资源标志符URI就是在某一规则下能把一个资源独一无二地标识出来。统一资源定位符URL就是用定位的方式实现的URI。 URI可被视为定位符(URL),名称(URN)或两者兼备。统一资源名(URN)如同一个人的名称,而统一资源定位符(URL)代表一个人的住址。换言之,URN定义某事物的身份,而URL提供查找该事物的方法。
4.File类,是一个静态类,主要是来提供一些函数库用的。静态实用类,提供了很多静态的方法,支持对文件的基本操作,包括创建,拷贝,移动,删除和打开一个文件。File类方法的参量很多时候都是路径path。File的一些方法可以返回FileStream和StreamWriter的对象。可以 和他们配套使用。System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间。
5.
private delegate void updateui(long rowCount, int i, ProgressBar PB);//一个委托类
long cl = GetFileSize(url);//获得文件大小cl
int readCount;
byte[] buffer = new byte[bufferSize];
readCount = ftpStream.Read(buffer, 0, bufferSize);//从流里读取的字节数为0时,则下载结束。
outputStream = new FileStream(newFileName, FileMode.Create);//输出流
float percent = 0;
while (readCount > 0)
{
outputStream.Write(buffer, 0, readCount);//写入
readCount = ftpStream.Read(buffer, 0, bufferSize);//写入
percent = (float)outputStream.Length / (float)cl * 100;//百分之多少了
if (percent <= 100)//进度条显示的百分比
{
if (pb != null)
{
pb.Invoke(new updateui(upui), new object[] { cl, (int)percent, pb });//进度条
// 首先代码定义了一个委托updateui(long rowCount, int i, ProgressBar PB),委托实例化
//委托与其带的参数类型数量相同。
//首先使用新的委托类型声明一个变量,并且初始化委托变量.注意,声明时的参数只要使用委托传递的函数的函数名,而不加括号
//upui:PB.Value = i;
}
}
}
public static long GetFileSize(string url)//获取大小就要重新连接吗?是的,method只能有一个
{
long fileSize = 0;
try
{
FtpWebRequest reqFtp = (FtpWebRequest)FtpWebRequest.Create(new Uri(url));//路径创造新的连接
reqFtp.UseBinary = true;
reqFtp.Credentials = new NetworkCredential(FTPUSERNAME, FTPPASSWORD);//连接
reqFtp.Method = WebRequestMethods.Ftp.GetFileSize;//方法大小
FtpWebResponse response = (FtpWebResponse)reqFtp.GetResponse();
fileSize = response.ContentLength;//获得大小
response.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return fileSize;
}
6. result.Append(line);//)Append 方法可用来将文本或对象的字符串表示形式添加到由当前 StringBuilder 对象表示的字符串的结尾处。
7. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);//读入responses所创建的数据流
string line = reader.ReadLine();//输入流中的下一行;如果到达了输入流的末尾,则为空引用
8.
int[] bcomp = new int[Len];
string[] a = new string[Len];
int[] bnum;
int[] bcomp = new int[Len];
a[i] = newstr.Substring(0, coo); //MessageBox.Show(a[i]);//名字给A
b[i] = newstr.Substring(coo);// MessageBox.Show(b[i]);//数字给B
bnum = Array.ConvertAll(b, int.Parse);//iNums = Array.ConvertAll<string, int>(sNums ,
// s => int.Parse(s)); iNums = Array.ConvertAll<string, int>(sNums, int.Parse);
Array.Clear(bcomp, 0, bcomp.Length);//清空这个bcomp数组
max = bcomp.Max();//选出最大的那个数字
9.
public partial class Form2 : Form//Partial是局部类型的意思。
//允许我们将一个类、结构或接口分成几个部分,分别实现在几个不同的.cs文件中。
//C#编译器在编译的时候仍会将各个部分的局部类型合并成一个完整的类
10.
public partial class Form2 : Form
{ public Form1 m_ff=new Form1 ();
}
public partial class Form1 : Form
{
private void button8_Click(object sender, EventArgs e)//前往配置
{
Form2 f2 = new Form2();
Hide();
f2.m_ff = this;
f2.Show();
}