FtpHelper類匿名獲取FTP檔案

2022-08-01 00:39:11 字數 2106 閱讀 4174

using system;

using system.collections.generic;

using system.io;

using system.linq;

using system.net;

using system.text;

using system.windows.forms;

using test;

namespace test

// to remove the trailing '\n'

result.remove(result.tostring().lastindexof('\n'), 1);

reader.close();

response.close();

return result.tostring().split('\n');

}catch (exception ex)

}/// /// 獲取檔案大小

///

/// ip伺服器下的相對路徑

/// 檔案大小

public static int getfilesize(string file)

catch (exception ex)

}/// /// 檔案上傳

///

/// 原路徑(絕對路徑)包括檔名

/// 目標資料夾:伺服器下的相對路徑 不填為根目錄

public static void fileupload(string filepath, string objpath = "")

console.writeline("上傳檔案成功");}}

}catch (exception ex)

finally

}catch (exception ex)

finally

}catch (exception ex)

}/// /// 刪除檔案

///

/// 伺服器下的相對路徑 包括檔名

public static void deletefilename(string filename)

catch (exception ex)

}/// /// 新建目錄 上一級必須先存在

///

/// 伺服器下的相對路徑

public static void makedir(string dirname)

catch (exception ex)

}/// /// 刪除目錄 上一級必須先存在

///

/// 伺服器下的相對路徑

public static void deldir(string dirname)

catch (exception ex)

}/// /// 從ftp伺服器上獲得資料夾列表

///

/// 伺服器下的相對路徑

///

public static listgetdirctory(string requedstpath)

line = reader.readline();

}reader.close();

response.close();

return strs;

}catch (exception ex)

return strs;

}/// /// 從ftp伺服器上獲得檔案列表

///

/// 伺服器下的相對路徑

///

public static listgetfile(string requedstpath)

line = reader.readline();

}reader.close();

response.close();

return strs;

}catch (exception ex)

return strs;

}public void download(string filename)

ftpstream.close();

outputstream.close();

response.close();

}catch (exception ex)}}

}

匿名物件和匿名類

一,匿名物件 匿名物件 沒有名字的物件 new car 匿名物件其實就是定義物件的簡寫格式。car c new car c.run 用匿名物件來書寫以上 new car run 匿名物件的使用方法 1 當物件對方法僅進行一次呼叫的時候,就可以簡化成匿名物件。如乙個 物件需要進行呼叫方法2次,用匿名物...

內,外,匿名類

1,單詞 arithmetic 算數,演算法 leak洩露 2,內部類介紹 1 在類中再定義乙個類。按著位置不同,分為 2種情況 a 成員位置 成員內部類,方法外 b 區域性位置 區域性內部類,方法內 2 在區域性位置的本地變數,或者區域性變數,只能使用 final 修飾,不能使用 private,...

巢狀類 匿名類 密封類

巢狀類 在c 中可以將乙個類定義在另乙個類的內部,外部的叫外部類,內部的巢狀類 namespace 27 set public void hello 巢狀類 public class web webname,weburl class program 匿名類 如果某個類的例項物件只會使用到一次,可以使...