C# FTP操作类

使用VMware Workstation 搭建docker服务器 搭建学习使用的docker服务器的过程,从虚拟机安装到docker服务安装再到镜像仓库配置等操作 阅读详情

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace Utility
{
    public class FtpUpDown
    {

        string ftpServerIP;

        string ftpUserID;

        string ftpPassword;

        FtpWebRequest reqFTP;

        private void Connect(String path)//连接ftp
        {

            // 根据uri创建FtpWebRequest对象

            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));

            // 指定数据传输类型

            reqFTP.UseBinary = true;

            // ftp用户名和密码

            reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

        }

        public FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword)
        {
            this.ftpServerIP = ftpServerIP;

            this.ftpUserID = ftpUserID;

            this.ftpPassword = ftpPassword;
        }

        //都调用这个

        private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表
        {
            string[] downloadFiles;
            StringBuilder result = new StringBuilder();
            try
            {
                Connect(path);

                reqFTP.Method = WRMethods;

                WebResponse response = reqFTP.GetResponse();

                StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名

                string line = reader.ReadLine();

                while (line != null)
                {

                    result.Append(line);

                    result.Append("\n");

                    line = reader.ReadLine();

                }

                // to remove the trailing '\n'

                result.Remove(result.ToString().LastIndexOf('\n'), 1);

                reader.Close();

                response.Close();

                return result.ToString().Split('\n');

            }

            catch (Exception ex)
            {
                Log.WriteError("Get FileList Error:" + ex.Message);
                downloadFiles = null;

                return downloadFiles;
            }
        }

        public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表
        {
            return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory);
        }
        public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表
        {
            return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory);
        }

        public void Upload(string filename) //上面的代码实现了从ftp服务器上载文件的功能
        {
            FileInfo fileInf = new FileInfo(filename);

            string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;

            Connect(uri);//连接        

            // 默认为true,连接不会被关闭

            // 在一个命令之后被执行

            reqFTP.KeepAlive = false;

            // 指定执行什么命令

            reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

            // 上传文件时通知服务器文件的大小

            reqFTP.ContentLength = fileInf.Length;
            // 缓冲大小设置为kb 
            int buffLength = 2048;
            byte[] buff = new byte[buffLength];

            int contentLen;

            // 打开一个文件流(System.IO.FileStream) 去读上传的文件

            FileStream fs = fileInf.OpenRead();

            try
            {

                // 把上传的文件写入流

                Stream strm = reqFTP.GetRequestStream();

                // 每次读文件流的kb

                contentLen = fs.Read(buff, 0, buffLength);

                // 流内容没有结束

                while (contentLen != 0)
                {
                    // 把内容从file stream 写入upload stream 
                    strm.Write(buff, 0, contentLen);
                    contentLen = fs.Read(buff, 0, buffLength);

                }

                // 关闭两个流

                strm.Close();

                fs.Close();

            }

            catch (Exception ex)
            {
                 Log.WriteError( "Upload Error:" + ex.Message);
            }

        }

        public bool Download(string filePath, string fileName, out string errorinfo)////上面的代码实现了从ftp服务器下载文件的功能
        {
            try
            {
                String onlyFileName = Path.GetFileName(fileName);

                string newFileName = filePath + "\\" + onlyFileName;

                if (File.Exists(newFileName))
                {

                    errorinfo = string.Format("本地文件{0}已存在,无法下载", newFileName);
                    return false;
                }
                string url = "ftp://" + ftpServerIP + "/" + fileName;
                Connect(url);//连接  
                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                Stream ftpStream = response.GetResponseStream();
                long cl = response.ContentLength;
                int bufferSize = 2048;
                int readCount;
                byte[] buffer = new byte[bufferSize];
                readCount = ftpStream.Read(buffer, 0, bufferSize);

                FileStream outputStream = new FileStream(newFileName, FileMode.Create);
                while (readCount > 0)
                {
                    outputStream.Write(buffer, 0, readCount);
                    readCount = ftpStream.Read(buffer, 0, bufferSize);
                }
                ftpStream.Close();
                outputStream.Close();
                response.Close();

                errorinfo = "";

                return true;

            }

            catch (Exception ex)
            {
                errorinfo = string.Format("因{0},无法下载", ex.Message);

                return false;

            }

        }

        //删除文件

        public void DeleteFileName(string fileName)
        {
            try
            {
                FileInfo fileInf = new FileInfo(fileName);

                string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;

                Connect(uri);//连接        

                // 默认为true,连接不会被关闭

                // 在一个命令之后被执行

                reqFTP.KeepAlive = false;

                // 指定执行什么命令

                reqFTP.Method = WebRequestMethods.Ftp.DeleteFile;

                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                response.Close();

            }

            catch (Exception ex)
            {
                Log.WriteError("删除错误:" + ex.Message);
            }

        }

        //创建目录

        public void MakeDir(string dirName)
        {
            try
            {
                string uri = "ftp://" + ftpServerIP + "/" + dirName;

                Connect(uri);//连接     

                reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory;

                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

                response.Close();

            }

            catch (Exception ex)
            {
                Log.WriteError("创建目录错误:" + ex.Message);
            }

        }

        //删除目录

        public void delDir(string dirName)
        {
            try
            {
                string uri = "ftp://" + ftpServerIP + "/" + dirName;

                Connect(uri);//连接     

                reqFTP.Method = WebRequestMethods.Ftp.RemoveDirectory;

                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

                response.Close();

            }

            catch (Exception ex)
            {
                Log.WriteError("删除目录错误:" + ex.Message);
            }

        }

        //获得文件大小

        public long GetFileSize(string filename)
        {

 

            long fileSize = 0;

            try
            {

                FileInfo fileInf = new FileInfo(filename);

                string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;

                Connect(uri);//连接     

                reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;

                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

                fileSize = response.ContentLength;

                response.Close();

            }

            catch (Exception ex)
            {
                Log.WriteError("获得文件大小错误:" + ex.Message);
            }

            return fileSize;

        }

        //文件改名

        public void Rename(string currentFilename, string newFilename)
        {
            try
            {
                FileInfo fileInf = new FileInfo(currentFilename);
                string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;
                Connect(uri);//连接
                reqFTP.Method = WebRequestMethods.Ftp.Rename;
                reqFTP.RenameTo = newFilename;
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                response.Close();

            }

            catch (Exception ex)
            {
                Log.WriteError("文件改名错误:" + ex.Message);
            }

        }
        //读取文件

        public Stream ReadFile(string fileName)
        {
            try
            {
                string url = "ftp://" + ftpServerIP + "/" + fileName;
                Connect(url);//连接  
                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                Stream ftpStream = response.GetResponseStream();
                return ftpStream;
            }

            catch (Exception ex)
            {
                Log.WriteError("读取文件错误:" + ex.Message);
                return null;
            }

        }

        //获得文件明晰

        public string[] GetFilesDetailList()
        {

            return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectoryDetails);

        }

        //获得文件明晰

        public string[] GetFilesDetailList(string path)
        {

            return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectoryDetails);

        }

        // 文件存在检查 
        public bool fileCheckExist(string fileName) 
        { 
            bool success = false;
            FtpWebResponse response = null;
            StreamReader reader = null;
            try 
            {
                string url = "ftp://" + ftpServerIP + "/" + fileName;
                Connect(url);//连接  
                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                response = (FtpWebResponse)reqFTP.GetResponse();
                reader = new StreamReader(response.GetResponseStream());
                string line = reader.ReadLine(); 
                if (line != null) 
                {
                    success = true; 
                } 
            } 
            catch (Exception) 
            {
                success = false; 
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (response != null)
                {
                    response.Close();
                }
            }
            return success; 
        } 
    }
}

匿名登录FTP

用 ftp_connect,ftp_login 匿名登录FTP时,用户名为:anonymous  密码为:空

FTP获取文件路径和子目录路径
 1         /// <summary>
 2         /// 从ftp服务器上获得文件列表
 3         /// </summary>
 4         /// <param name="RequedstPath"></param>
 5         /// <returns></returns>
 6         public static List<string> GetDirctory(string RequedstPath)
 7         {
 8             List<string> strs = new List<string>();
 9             try
10             {
11                 string uri = path + RequedstPath;   //目标路径 path为服务器地址
12                 FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
13                 // ftp用户名和密码
14                 reqFTP.Credentials = new NetworkCredential(username, password);
15                 reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
16                 WebResponse response = reqFTP.GetResponse();
17                 StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名
18 
19                 string line = reader.ReadLine();
20                 while (line != null)
21                 {
22                     if (line.Contains("<DIR>"))
23                     {
24                         string msg = line.Substring(line.LastIndexOf("<DIR>")+5).Trim();
25                         strs.Add(msg);
26                     }
27                     line = reader.ReadLine();
28                 }
29                 reader.Close();
30                 response.Close();
31                 return strs;
32             }
33             catch (Exception ex)
34             {
35                 Console.WriteLine("获取目录出错:" + ex.Message);
36             }
37             return strs;
38         }
39 
40         /// <summary>
41         /// 从ftp服务器上获得文件
42         /// </summary>
43         /// <param name="RequedstPath">相对服务器路径</param>
44         /// <returns></returns>
45         public static List<string> GetFile(string RequedstPath)
46         {
47             List<string> strs = new List<string>();
48             try
49             {
50                 string uri = path + RequedstPath;   //目标路径 path为服务器地址
51                 FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
52                 // ftp用户名和密码
53                 reqFTP.Credentials = new NetworkCredential(username, password);
54                 reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
55                 WebResponse response = reqFTP.GetResponse();
56                 StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名
57 
58                 string line = reader.ReadLine();
59                 while (line != null)
60                 {
61                     if (!line.Contains("<DIR>"))
62                     {
63                         string msg = line.Substring(39).Trim();
64                         strs.Add(msg);
65                         Console.WriteLine(msg);
66                     }
67                     line = reader.ReadLine();
68                 }
69                 reader.Close();
70                 response.Close();
71                 return strs;
72             }
73             catch (Exception ex)
74             {
75                 Console.WriteLine("获取文件出错:" + ex.Message);
76             }
77             return strs;
78         }

 

知道如何获取文件和目录,剩下的就是一个递归而已。这个很简单,不说明了。递归这东西好玩,但是效率很低。

Ron Ngai  | 园豆:358  (菜鸟二级)  | 2012-07-25 18:28
        /// <summary>
        /// 从ftp服务器上获得文件列表
        /// </summary>
        /// <param name="RequedstPath"></param>
        /// <returns></returns>
        public static List<string> GetDirctory(string RequedstPath)
        {
            List<string> strs = new List<string>();
            try
            {
                string uri = path + RequedstPath;   //目标路径 path为服务器地址
                FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
                // ftp用户名和密码
                reqFTP.Credentials = new NetworkCredential(username, password);
                reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                WebResponse response = reqFTP.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名

                string line = reader.ReadLine();
                while (line != null)
                {
                    if (line.Contains("<DIR>"))
                    {
                        string msg = line.Substring(line.LastIndexOf("<DIR>")+5).Trim();
                        strs.Add(msg);
                    }
                    line = reader.ReadLine();
                }
                reader.Close();
                response.Close();
                return strs;
            }
            catch (Exception ex)
            {
                Console.WriteLine("获取目录出错:" + ex.Message);
            }
            return strs;
        }

        /// <summary>
        /// 从ftp服务器上获得文件
        /// </summary>
        /// <param name="RequedstPath">相对服务器路径</param>
        /// <returns></returns>
        public static List<string> GetFile(string RequedstPath)
        {
            List<string> strs = new List<string>();
            try
            {
                string uri = path + RequedstPath;   //目标路径 path为服务器地址
                FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
                // ftp用户名和密码
                reqFTP.Credentials = new NetworkCredential(username, password);
                reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                WebResponse response = reqFTP.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名

                string line = reader.ReadLine();
                while (line != null)
                {
                    if (!line.Contains("<DIR>"))
                    {
                        string msg = line.Substring(39).Trim();
                        strs.Add(msg);
                        Console.WriteLine(msg);
                    }
                    line = reader.ReadLine();
                }
                reader.Close();
                response.Close();
                return strs;
            }
            catch (Exception ex)
            {
                Console.WriteLine("获取文件出错:" + ex.Message);
            }
            return strs;
        }

OpenEuler学习笔记5-使用VMware Workstation 17虚拟机安装OpenEuler服务器系统 openEuler是由开放原子开源基金会孵化的全场景开源操作系统项目,面向数字基础设施四大核心场景(服务器、云计算、边缘计算、嵌入式),全面支持ARM、x86、RISC-V、loongArch、PowerPC、SW-64等多样性计算架构 openEuler 25.09 是基于6.6内核的创新版本,面向服务器、云、边缘计算和嵌入式场景,提供更多新特性和功能,给开发者和用户带来全新的体验,服务更多的领域和更多的用户。 阅读详情

相关推荐

VMware 系列:VMware ESXI 7服务器中安装虚拟机(全过程超详细含中英文对照,附应知必会的理论基础和常见故障解决方案)

VMware 系列:VMware ESXI 7服务器中安装虚拟机(全过程超详细含中英文对照,附应知必会的理论基础和常见故障解决方案)

weixin_54626591的博客 1929

C#-FTP相关操作的简单封装

【代码】C#-FTP相关操作的封装。

rwo_bear的博客 1993

c# FTP操作类

c#对 FTP操作类 上传下载 增删查改

C#对FTP服务器操作类

TreeView控件显示目录结构,ListView显示文件列表。通过类实现与 FTP 服务器的交互,如列出文件、上传和下载。通过右键菜单和双击事件,支持用户下载和上传文件,提供类似访问本地文件系统的体验。这样,用户可以通过 WinForms 的图形界面与 FTP 服务器交互,类似于本地文件系统的操作体验。

tianminhjyusaf的博客 844

C#操作ftp类完整实例

本文实例讲述了C#操作ftp类。分享给大家供大家参考。具体如下: using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net; using System.Globalization; namespace FtpTest1 { public class FtpWeb { string ftpServerIP; string ftpRemotePath; string ftpUserID; string ftpPassword; string

数控弯管机xyz转换ybc的算法_花了一年时间开发的三维弯管机交互式转档软件(三维管子模型UG,SOLIDWORK,PRO/E文件转成YBC)...

在弯管机加工中,由管子模型生成可直接进行弯管加工的YBC数据可以大大提高弯管编程过程.传统的做法是先用dxf数据文件(用autocad绘制管子的轴心线数据)转出XYZ数据,然后由XYZ数据转成YBC数据,而且大部分厂家对文件版本以及软件做管方式都有不少限制,这大大花费了用户的时间跟精力.随着企业的信息化管理以及不断的技术升级,传统用autocad线条模式来描述管子的方式正在被用户用PRO/E,UG...

weixin_29065959的博客 1968

C#FTP对文件的操作

文章目录一、FTP是什么?二、FTP文件操作1.Ftp数据加载2.Ftp文件上传3.Ftp文件下载4.Ftp文件删除项目演示: 一、FTP是什么? FTP是用来在两台计算机之间传输文件 二、FTP文件操作 1.Ftp数据加载 代码如下(示例): /// <summary> /// Ftp数据加载 /// </summary> /// <param name="F_Ftp">FTP服务器IP</param> /// <param name="F_Use.

GengGeng7777的博客 2081

nmap、X-Scan漏洞扫描和Metasploit中用永恒之蓝漏洞入侵靶机并上传冰河

利用nmap、X-Scan扫描靶机的漏洞,在Metasploit中用扫描出的永恒之蓝漏洞入侵靶机,建立连接后上传冰河木马控制靶机,最后用冰河陷阱清除靶机的冰河木马,记一次完整的入侵控制实验。

m0_59302403的博客 4409

VMware-converter实现服务器向VMware虚拟化平台热迁移

本文演示通过VMware-converter工具,将服务器(虚拟机或物理机)向VMware虚拟化平台ESXI、vCenter、Workstation个人版进行热迁移。

doctorxusong的博客 3396

DeepLearning tutorial(7)深度学习框架Keras的使用-进阶

上一篇文章总结了Keras的基本使用方法,相信用过的同学都会觉得不可思议,太简洁了。十多天前,我在github上发现这个框架的时候,关注Keras的人还比较少,这两天无论是github还是微薄,都看到越来越多的人关注和使用Keras。所以这篇文章就简单地再介绍一下Keras的使用,方便各位入门。主要包括以下三个内容: 训练CNN并保存训练好的模型。 将CNN用于特征提取,用提取出来的特征训练SVM。

wepon的专栏 2万+

LLM Wiki 的完整输入体系:LLM Wiki极简实战

LLM Wiki 的输入分为**四大类**,覆盖从"原始知识注入"到"系统行为控制"的全流程,所有输入都遵循"**原始资料不可变,规则可迭代,人类反馈闭环**"的核心原则。

ZhangJiqun&191cm&85kg 328

利用vmware在自己的个人电脑上面搭建虚拟linux服务器

学习linux的第一步当然是搭建一个linux环境了 搭建linux环境有两种选择:第一种不差钱的,直接弄一台物理机,这个的话基本不在本次介绍范围内。 第二种就是搭建虚拟机,利用自己个人电脑虚拟出一个linux环境。 我自己的pc机为 windows10 ,使用的虚拟化软件为VMware® Workstation 12 Pro,当然这个软件就不只一个了,可以根据自己喜

Ray的博客 2万+

2023年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题4)-网络部分解析-附详细代码

2023年全国职业院校技能大赛网络系统管理赛项模块A:网络构建(样题4)-网络部分解析-附详细代码

bfq05234214的博客 441

VmWare中安装CenterOs(内网服务器)

由于CentOS 7 已于2024年6月30日停止维护,官方仓库就没有软件了,想要在继续使用 ,需要更换软件,仓库这里,我使用的是阿里的软件仓库。11、如果是内网服务器,他需要一个固定的ip: 比如就设置为192.168.110.128,这样局域网同网段下的人就可以直连了。已经停止维护,部分镜像网站移除了对centos 7的支持,这里找到了部分现在还可以使用的镜像网站。更改DHCP模式为static,然后输入刚刚更改的IP地址,顺序依次为IP,子网掩码,网关。这样你的电脑上会出现虚拟网卡,请不要禁用他。

山路曲折盘旋,但毕竟朝着顶峰延伸 2078

YOLOv11改进 | 主干/Backbone篇 | 轻量级移动端网络ShuffleNetV2(附代码+修改教程)

本文给大家带来的改进内容是ShuffleNetV2,这是一种为移动设备设计的高效CNN架构。其在ShuffleNetV1的基础上强调除了FLOPs之外,还应考虑速度、内存访问成本和平台特性。(我在YOLOv11n上修改该主干降低了GFLOPs,但是参数量还是有一定上涨,其非常适合轻量化的读者来使用,同时精度也有一定程度的上涨)。本文通过介绍其主要框架原理,然后教你如何添加该网络结构到网络模型中。

Snu77的博客 3388

粒子群优化与蚁群算法求解多旅行商问题

它要求在给定一组城市和旅行商之间的距离矩阵的情况下,找到一条最优的路径方案,使得所有旅行商可以分别从起始城市出发,途径其他城市,并最终回到起始城市,同时总旅行距离达到最小。这两种算法都是基于群体智能的优化算法,在求解组合优化问题时具有较好的性能表现。假设有n个城市需要被m个旅行商访问,城市间的距离由距离矩阵D表示,其中D(i,j)表示第i个城市到第j个城市的距离。粒子群优化算法是一种基于群体智能的优化算法,其中的粒子代表了潜在的解,并通过模拟粒子在解空间中的移动来搜索最优解。一、多旅行商问题建模。

m0_47037246的博客 553

轻松创建英文版VMware虚拟机

在弹出语言选择后选择English,之后再根据图中圈画部分由上到下分别进行点击与操作,最后再进行账户的创建。15.完成创建,但英文版的虚拟机创建还没结束,需检查网络声卡等方面。9.选择虚拟机文件安装位置,并给虚拟机命名(根据实际需求调整)7.选择镜像文件位置(安装虚拟机之前应提前安装映像文件)(根据我们电脑实际情况进行选择,推荐为实际的一半)4.开始虚拟机的创建:点击文件,选择创建虚拟机。11.点击下一步后,磁盘类型选择NVMe(V)要选择稍后安装操作系统,后点击下一步,5.选择自定义,再点击下一步。

comicCal的博客 79

Codex 100个真实案例 - 用AI批量清洗Excel脏数据(10万行3分钟搞定)

每个做数据分析的人都被"脏数据"折磨过——空值、重复行、日期格式五花八门、手机号多一位少一位……手动清洗几千行就已经让人崩溃,更别提10万行了。本文将展示如何用 Codex 生成一套完整的 Python pandas 数据清洗工具,从读取Excel/CSV、识别脏数据、自动清洗、生成清洗报告,到可视化对比清洗前后的数据质量,全程自然语言驱动,10万行数据3分钟搞定!

yueyeguzhuo的专栏 88

如何使用VMware搭建linux(CentOS)服务器

一、概述 在软件开发过程中,为了便于我们开发、测试自己的代码时,不影响其他人的使用,通常我们需要一个自己的开发测试环境,这个时候我们就可以使用虚拟化技术来搭建自己的单台服务器或者服务器机器。同时,很多时候我们需要学习新的技术如redis/kafka/zookeeper/hadoop/ELK/spark等,学习的时候我们都需要有这样一个环境,这是也需要我们能搭建这些环境,而这些环境搭建的基础就是需...

诸葛小猿 1万+

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

VMware Converter 转换过程(一)----英文版

温故: 在前面的几篇文章中我和大家聊了两个内容,分别是克隆和NTP时钟同步。关于克隆主要讲了热克隆和冷克隆的区别,还有克隆的模式,如基于卷的克隆、基于磁盘的克隆和基于链接的克隆。然后再NTP的文章中又和大家聊了NTP 的作用以及NTP如何进行配置,希望大家能够有所收获。关于上面提到的文章的链接如下: VMware P2V----克隆(一) VMware P2V----克隆(二) NTP时钟同步的设置 知新: 下面举一个安装并迁移的例子 我们下载vmware vcenter converter开

Gao068465的博客 2530

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

轻松上手:VMware虚拟机中安装Ubuntu 22.04英文桌面环境教程

轻松上手:VMware虚拟机中安装Ubuntu 22.04英文桌面环境教程 去发现同类优质开源项目:https://gitcode.com/ 项目介绍 在当今的数字化时代,Linux操作系统因其开源、稳定和灵活的特性,越来越受到开发者和企业的青睐。Ubuntu作为最受欢迎的Linux发行版之一,其最新版本Ubuntu 22.04更是带来了诸多新特性和改进。然而,对于许多初学者来说,如何在虚拟机中安...

gitblog_06559的博客 459

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

C#FTP操作类

using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net; using System.Globalization; namespace FtpTest1 { public class FtpWeb { string ftpServerIP; string ftpRemotePath; string ftpUserID; string ftpPasswor

weixin_44599955的博客 286

C# ftp操作类

using System; using System.Text; using System.IO; using System.Net; namespace Himall.Core.Helper {     public class FtpHelper     {         string ftpServerIP;         string ftpRemot

u012992280的专栏 446

FtpUpDownLoad~

using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Windows.Forms; namespace ConvertData{    class FtpUpDownLoad    {       

raineo的专栏 577
上一篇: C# FTP操作类
下一篇: Mapxtreme 加载地图
devgis
博客等级 码龄16年 52粉丝 60原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值