C# FTP操作類庫

640?wx_fmt=jpeg

class FTP_Class

? ? {

? ? ? ? string ftpServerIP;

? ? ? ? string ftpUserID;

? ? ? ? string ftpPassword;

? ? ? ? FtpWebRequest reqFTP;? ? ??

? ? ? ? #region 連接

? ? ? ? /// <summary>

? ? ? ? /// 連接FtpWebRequest

? ? ? ? /// </summary>

? ? ? ? /// <param name="path"></param>

? ? ? ? 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);

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region ftp登錄信息

? ? ? ? /// <summary>

? ? ? ? /// ftp登錄信息

? ? ? ? /// </summary>

? ? ? ? /// <param name="ftpServerIP">FtpIP地址</param>

? ? ? ? /// <param name="ftpUserID">ftp用戶名</param>

? ? ? ? /// <param name="ftpPassword">ftp密碼</param>

? ? ? ? public void FtpUpDown(string ftpServerIP, string ftpUserID, string ftpPassword)

? ? ? ? {

? ? ? ? ? ? this.ftpServerIP = ftpServerIP;

? ? ? ? ? ? this.ftpUserID = ftpUserID;

? ? ? ? ? ? this.ftpPassword = ftpPassword;

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 獲取文件列表

? ? ? ? /// <summary>

? ? ? ? /// 上面的代碼示例了如何從ftp服務器上獲得文件列表

? ? ? ? /// </summary>

? ? ? ? /// <param name="path">URL路徑</param>

? ? ? ? /// <param name="WRMethods"></param>

? ? ? ? /// <returns>String[] </returns>

? ? ? ? private string[] GetFileList(string path, string WRMethods) //內部方法

? ? ? ? {

? ? ? ? ? ? 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.UTF8);//中文文件名

? ? ? ? ? ? ? ? string line = reader.ReadLine();

? ? ? ? ? ? ? ? while (line != null)

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? result.Append(line);

? ? ? ? ? ? ? ? ? ? result.Append("\n");? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? line = reader.ReadLine(); //讀取下一行

? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ?

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

? ? ? ? ? ? ? ? reader.Close();

? ? ? ? ? ? ? ? response.Close();

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

? ? ? ? ? ? }

? ? ? ? ? ? catch (Exception ex)

? ? ? ? ? ? {


? ? ? ? ? ? ? ? Console.WriteLine(ex.Message);

? ? ? ? ? ? ? ? downloadFiles = null;

? ? ? ? ? ? ? ? return downloadFiles;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ?/// <summary>

? ? ? ?///根據知道的文件路徑得到文件列表

? ? ? ?/// </summary>

? ? ? ?/// <param name="path"></param>

? ? ? ?/// <returns></returns>

? ? ? ? public string[] GetFileList(string path)

? ? ? ? {

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

? ? ? ? }

? ? ? ? /// <summary>

? ? ? ? /// 默認URl文件列表

? ? ? ? /// </summary>

? ? ? ? /// <returns></returns>

? ? ? ? public string[] GetFileList()

? ? ? ? {

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

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 上傳文件

? ? ?/// <summary>

? ? ?///從ftp服務器上載文件的功能

? ? ?/// </summary>

? ? ?/// <param name="filename">要上傳的文件</param>

? ? ?/// <param name="path">上傳的路徑</param>

? ? ?/// <param name="errorinfo">返回信息</param>

? ? ?/// <returns></returns>

? ? ? ? public bool Upload(string filename, string path, out string errorinfo)?

? ? ? ? {

? ? ? ? ? ? path = path.Replace("\\", "/");

? ? ? ? ? ? FileInfo fileInf = new FileInfo(filename);

? ? ? ? ? ? string uri = "ftp://" + path + "/" + 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();

? ? ? ? ? ? ? ? errorinfo = "完成";

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? ? ? catch (Exception ex)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? errorinfo = string.Format("因{0},無法完成上傳", ex.Message);

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 續傳文件

? ? ? ?/// <summary>

? ? ? ? /// 續傳文件

? ? ? ?/// </summary>

? ? ? ?/// <param name="filename">文件名</param>

? ? ? ?/// <param name="size">文件的大小</param>

? ? ? ?/// <param name="path">路徑</param>

? ? ? ?/// <param name="errorinfo">返回信息</param>

? ? ? ?/// <returns></returns>

? ? ? ? public bool Upload(string filename, long size, string path, out string errorinfo)?

? ? ? ? {

? ? ? ? ? ? path = path.Replace("\\", "/");

? ? ? ? ? ? FileInfo fileInf = new FileInfo(filename);

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

? ? ? ? ? ? string uri = "ftp://" + path;

? ? ? ? ? ? Connect(uri);//連接? ? ? ? ?

? ? ? ? ? ? // 默認為true,連接不會被關閉

? ? ? ? ? ? // 在一個命令之后被執行

? ? ? ? ? ? reqFTP.KeepAlive = false;

? ? ? ? ? ? // 指定執行什么命令? ? ? ? ?

? ? ? ? ? ? reqFTP.Method = WebRequestMethods.Ftp.AppendFile;

? ? ? ? ? ? // 上傳文件時通知服務器文件的大小

? ? ? ? ? ? reqFTP.ContentLength = fileInf.Length;

? ? ? ? ? ? // 緩沖大小設置為kb?

? ? ? ? ? ? int buffLength = 2048;

? ? ? ? ? ? byte[] buff = new byte[buffLength];

? ? ? ? ? ? int contentLen;

? ? ? ? ? ? // 打開一個文件流(System.IO.FileStream) 去讀上傳的文件

? ? ? ? ? ? FileStream fs = fileInf.OpenRead();

? ? ? ? ? ? try

? ? ? ? ? ? {

? ? ? ? ? ? ? ? StreamReader dsad = new StreamReader(fs);

? ? ? ? ? ? ? ? fs.Seek(size, SeekOrigin.Begin);

? ? ? ? ? ? ? ? // 把上傳的文件寫入流

? ? ? ? ? ? ? ? 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();

? ? ? ? ? ? ? ? errorinfo = "完成";

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? ? ? catch (Exception ex)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? errorinfo = string.Format("因{0},無法完成上傳", ex.Message);

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 下載文件

? ? ? ? /// <summary>

? ? ? ? /// 上面的代碼實現了從ftp服務器下載文件的功能

? ? ? ? /// </summary>

? ? ? ? /// <param name="filePath">文件</param>

? ? ? ? /// <param name="fileName"></param>

? ? ? ? /// <param name="errorinfo"></param>

? ? ? ? /// <returns></returns>

? ? ? ? public bool Download(string ftpfilepath, string filePath, string fileName, out string errorinfo)

? ? ? ? {

? ? ? ? ? ? try

? ? ? ? ? ? {

? ? ? ? ? ? ? ? filePath = filePath.Replace("我的電腦\\", "");

? ? ? ? ? ? ? ? String onlyFileName = Path.GetFileName(fileName);

? ? ? ? ? ? ? ? string newFileName = filePath + onlyFileName;

? ? ? ? ? ? ? ? if (File.Exists(newFileName))

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? errorinfo = string.Format("本地文件{0}已存在,無法下載", newFileName);

? ? ? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ftpfilepath = ftpfilepath.Replace("\\", "/");

? ? ? ? ? ? ? ? string url = "ftp://" + ftpfilepath;

? ? ? ? ? ? ? ? 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;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 刪除文件

? ? ? ? /// <summary>

? ? ? ? /// 刪除文件

? ? ? ? /// </summary>

? ? ? ? /// <param name="fileName"></param>

? ? ? ? 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)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? //MessageBox.Show(ex.Message, "刪除錯誤");

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 在ftp上創建目錄

? ? ? ? /// <summary>

? ? ? ? /// 在ftp上創建目錄

? ? ? ? /// </summary>

? ? ? ? /// <param name="dirName"></param>

? ? ? ? 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)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // MessageBox.Show(ex.Message);

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 刪除ftp上目錄

? ? ? ? /// <summary>

? ? ? ? /// 刪除ftp上目錄

? ? ? ? /// </summary>

? ? ? ? /// <param name="dirName"></param>

? ? ? ? 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)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // MessageBox.Show(ex.Message);

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 獲得ftp上文件大小

? ? ? ? /// <summary>

? ? ? ? /// 獲得ftp上文件大小

? ? ? ? /// </summary>

? ? ? ? /// <param name="filename"></param>

? ? ? ? /// <returns></returns>

? ? ? ? public long GetFileSize(string filename)

? ? ? ? {

? ? ? ? ? ? long fileSize = 0;

? ? ? ? ? ? filename = filename.Replace("\\", "/");

? ? ? ? ? ? try

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // FileInfo fileInf = new FileInfo(filename);

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

? ? ? ? ? ? ? ? // string uri = filename;

? ? ? ? ? ? ? ? string uri = "ftp://" + filename;

? ? ? ? ? ? ? ? Connect(uri);//連接? ? ??

? ? ? ? ? ? ? ? reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;

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

? ? ? ? ? ? ? ? fileSize = response.ContentLength;

? ? ? ? ? ? ? ? response.Close();

? ? ? ? ? ? }

? ? ? ? ? ? catch (Exception ex)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // MessageBox.Show(ex.Message);

? ? ? ? ? ? }

? ? ? ? ? ? return fileSize;

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region ftp上文件改名

? ? ? ? /// <summary>

? ? ? ? /// ftp上文件改名

? ? ? ? /// </summary>

? ? ? ? /// <param name="currentFilename"></param>

? ? ? ? /// <param name="newFilename"></param>

? ? ? ? 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();

? ? ? ? ? ? ? ? //Stream ftpStream = response.GetResponseStream();

? ? ? ? ? ? ? ? //ftpStream.Close();

? ? ? ? ? ? ? ? response.Close();

? ? ? ? ? ? }

? ? ? ? ? ? catch (Exception ex)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? // MessageBox.Show(ex.Message);

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? #endregion


? ? ? ? #region 獲得文件明晰

? ? ? ? /// <summary>

? ? ? ? /// 獲得文件明晰

? ? ? ? /// </summary>

? ? ? ? /// <returns></returns>

? ? ? ? public string[] GetFilesDetailList()

? ? ? ? {

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

? ? ? ? }

? ? ? ? /// <summary>

? ? ? ? /// 獲得文件明晰

? ? ? ? /// </summary>

? ? ? ? /// <param name="path"></param>

? ? ? ? /// <returns></returns>

? ? ? ? public string[] GetFilesDetailList(string path)

? ? ? ? {

? ? ? ? ? ? path = path.Replace("\\", "/");

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

? ? ? ? }

? ? ? ? #endregion


? ? }


本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/272416.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/272416.shtml
英文地址,請注明出處:http://en.pswp.cn/news/272416.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

安裝并配置ROS環境

參考該網址內容&#xff1a;http://wiki.ros.org/cn/ROS/Tutorials/InstallingandConfiguringROSEnvironment

Cropper – 簡單的 jQuery 圖片裁剪插件

Cropper 是一個簡單的 jQuery 圖像裁剪插件。它支持選項&#xff0c;方法&#xff0c;事件&#xff0c;觸摸&#xff08;移動&#xff09;&#xff0c;縮放&#xff0c;旋轉。輸出的裁剪數據基于原始圖像大小&#xff0c;這樣你就可以用它們來直接裁剪圖像。 如果你嘗試裁剪跨域…

C# JSON格式數據用法

JSON簡介JSON(全稱為JavaScript ObjectNotation) 是一種輕量級的數據交換格式。它是基于JavaScript語法標準的一個子集。JSON采用完全獨立于語言的文本格式&#xff0c;可以很容易在各種網絡、平臺和程序之間傳輸。JSON的語法很簡單&#xff0c;易于人閱讀和編寫&#xff0c;同…

Ros命令及功能

運行小烏龜代碼&#xff1a; roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key一些命令及作用 ros 加tap //查看電腦中以ros開頭的命令 rqt_graph //將系統內的主要資源以可視化的形式展現出來 rosnode list //列出系統節點 命令 --help //查看命…

數據庫——環境初建改端口和密碼(轉)

一、修改APACHE的監聽端口 2、在界面中選apache&#xff0c;彈出隱藏菜單選項&#xff0c;打開配置文件httpd.conf; 2、找到Listen 80 和 ServerName localhost:80; 3、將80改成801&#xff08;當然自己也可以設定別的不使用的端口&#xff0c;例如8000等&#xff09;; 4、保存…

文件系統認知

什么是文件系統 常規認知是&#xff1a;linux根目錄那些東西 百科&#xff1a;文件系統是操作系統用于明確存儲設備組織文件的方法&#xff0c;操作系統中負責管理和存儲文件信息的軟件機構稱為文件管理系統&#xff0c;簡稱文件系統。 以上說的方法&#xff1a;就是文件管理…

何謂悲觀鎖與樂觀鎖

樂觀鎖對應于生活中樂觀的人總是想著事情往好的方向發展&#xff0c;悲觀鎖對應于生活中悲觀的人總是想著事情往壞的方向發展。這兩種人各有優缺點&#xff0c;不能不以場景而定說一種人好于另外一種人。 悲觀鎖 總是假設最壞的情況&#xff0c;每次去拿數據的時候都認為別人會…

寒哥細談之AutoLayout全解

看到群中好多朋友還停留在Frame布局的痛苦時代&#xff0c;以及有些開發者接手別人的就項目發現布局一團亂。而且沒有啟動圖的時候并不是真正真正適配iPhone 6(S)、iPhone6(S) Plus等設備 。寒哥準備盡可能詳細的講一講我所掌握的AutoLayout 。AutoLayout很難&#xff1f;我覺得…

最難學的5種編程語言排行

每個程序員都熟悉許多編程語言。許多編程語言都是高級的&#xff0c;它們的語法是人類可讀的。然而&#xff0c;也有一些低級語言&#xff0c;對于一個人來說&#xff0c;讀起來很困難&#xff0c;但是可以理解。然而&#xff0c;您是否遇到過一種既不可讀又不可理解的編程語言…

[小北De編程手記] : Lesson 02 - Selenium For C# 之 核心對象

從這一篇開始&#xff0c;開始正式的介紹Selenium 以及相關的組件&#xff0c;本文的將討論如下問題&#xff1a; Selenium基本的概念以及在企業化測試框架中的位置Selenium核心對象&#xff08;瀏覽器驅動&#xff09; Web DriverSelenium核心對象&#xff08;Dom元素&#xf…

Java中HashMap的entrySet()你會用了嗎

Map中存放的元素均為鍵值對&#xff0c;故每一個鍵值對必然存在一個映射關系。 Map中采用Entry內部類來表示一個映射項&#xff0c;映射項包含Key和Value Map.Entry里面包含getKey()和getValue()方法 Set<Entry<T,V>> entrySet() 該方法返回值就是這個map中各個鍵…

JS獲取請求URL相關參數

今天在找獲取當前網址除去參數的js方式&#xff0c;結果自己會的竟然只有window.location.href 先看一個示例 用javascript獲取url網址信息 <script type"text/javascript"> document.write("location.host"location.host"<br>"); d…

wiki語法大全

Wiki語法大全 編輯一個維客頁面十分容易。只要點擊頁面上方的“編輯本頁”或右側的[編輯]鏈接即可修改該頁&#xff0c;或點擊“討論本頁”然后再點擊“編輯頁面”來討論該頁面。點擊后您就會看到一個包含那個Wiki頁面的可編輯的文字區域。 先將文字復制到您最喜歡的文字編輯器…

驅動認知

用戶態 App&#xff1a;cp指令&#xff0c;ftp的項目等等這就是App的開發。 App開發需要C的基礎和C庫&#xff0c;C庫講到文件&#xff0c;進程&#xff0c;進程間通信&#xff0c;線程&#xff0c;網絡&#xff0c;界面&#xff08;GTk&#xff09;。 C庫&#xff08;是linux標…

TreeMap實現排序

TreeMap TreeMap實現SortMap接口&#xff0c;能夠把它保存的記錄根據鍵排序&#xff0c;默認是按鍵值的升序排序&#xff0c;也可以指定排序的比較器。當用Iterator遍歷TreeMap時&#xff0c;得到的記錄是排過序的。 TreeMap取出來的是排序后的鍵值對。但如果您要按自然順序或…

圖解分布式架構的演進過程!

一、什么是分布式架構分布式系統&#xff08;distributed system&#xff09; 是建立在網絡之上的軟件系統。內聚性&#xff1a;是指每一個數據庫分布節點高度自治&#xff0c;有本地的數據庫管理系統。透明性&#xff1a;是指每一個數據庫分布節點對用戶的應用來說都是透明的&…

CSS 布局實例系列(四)如何實現容器中每一行的子容器數量隨著瀏覽器寬度的變化而變化?...

Hello&#xff0c;小朋友們&#xff0c;還記得我是誰嗎&#xff1f;對了&#xff0c;我就是~超威~好啦&#xff0c;言歸正傳&#xff0c;今天的布局實例是&#xff1a; 實現一個浮動布局&#xff0c;紅色容器中每一行的藍色容器數量隨著瀏覽器寬度的變化而變化&#xff0c;就如…

基于框架編寫驅動代碼

操作驅動的上層代碼&#xff08;pin4test&#xff09; #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>void main() {int fd,data;fd open("/dev/pin4",O_RDWR);if(fd<0){printf("open fail…

nacos在windows下安裝

1:訪問https://github.com/alibaba/nacos/releases下載nacos 2:下載到本地解壓 3:點擊startup.cmd 啟動nacos 4:訪問 http://127.0.0.1:8848/nacos 輸入賬號和密碼&#xff0c;nacos/nacos

關于SQL優化這些你了解嗎?

背景在當今這個互聯網的時代無非要解決兩大難題&#xff0c;其一是信息安全&#xff0c;其二就是數據的存儲。而信息安全則是在數據存儲的基礎之上。一個公司從剛開始成立到發展成一個有上百人甚至上千人團隊的時候&#xff0c;公司的業務量是呈上升趨勢&#xff0c;客戶及用戶…