后台代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.IO;
using System.Xml;
using System.Net;
using BLL;
namespace AlumnusManage
{
public partial class UploadData : UserControl
{
private FTPclient myFTPclient;
private XY myXY = new XY();
private List<string> fileName = new List<string>();
private bool checkFlog = false;
private bool uploadFLog = false;
private bool checkedFlog = false;
public UploadData()
{
InitializeComponent();
this.BackColor = Main.bgColor;
dataGridView1.BackgroundColor = Main.bgColor;
}
~UploadData()
{
myFTPclient = null;
}
public static string GetLinkStr(string _key)
{
string filePath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "AlumnusManage.exe.config";
XmlDocument myDoc = new XmlDocument();
myDoc.Load(filePath);
XmlNode objContentNode = myDoc.SelectSingleNode("//appSettings"); //声明XmlNode对象
//
XmlElement xElem1 = (XmlElement)objContentNode.SelectSingleNode("//add[@key='" + _key + "']");
string str = xElem1.GetAttribute("value");
string key = "Rainight";
DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
provider.Key = Encoding.ASCII.GetBytes(key.Substring(0, 8));
provider.IV = Encoding.ASCII.GetBytes(key.Substring(0, 8));
byte[] buffer = new byte[str.Length / 2];
for (int i = 0; i < (str.Length / 2); i++)
{
int num2 = Convert.ToInt32(str.Substring(i * 2, 2), 0x10);
buffer[i] = (byte)num2;
}
MemoryStream stream = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(), CryptoStreamMode.Write);
stream2.Write(buffer, 0, buffer.Length);
stream2.FlushFinalBlock();
stream.Close();
return Encoding.GetEncoding("GB2312").GetString(stream.ToArray());
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
pictureBox1.Visible = true;
myFTPclient = new FTPclient(GetLinkStr("IPAddr"), "xyb_upload", "xyb2010shujushangchuan");
myFTPclient.port = 8765;
&nb

这是一个.NET应用示例,通过FTPclient类实现在局域网内的大文件批量上传功能。代码中包含了目录遍历、文件上传及文件类型的校验,确保上传文件的安全性。背景是在AlumnusManage项目中,用于班级、教师和校友资料的上传。
最低0.47元/天 解锁文章
2831

被折叠的 条评论
为什么被折叠?



