Ftp上傳的方法

2021-09-07 20:22:51 字數 3105 閱讀 6396

using system;

using system.collections.generic;

using system.io;

using system.net;

using system.text;

namespace evms.common.data

///

/// 上傳

///

///

public void upload(string filename)

strm.close();

fs.close();

}catch (exception ex)

}///

///

public void download(string filepath, string filename)

ftpstream.close();

outputstream.close();

response.close();

}catch (exception ex)

}///

/// 刪除檔案

///

///

public void delete(string filename)

catch (exception ex)

}///

/// 刪除資料夾

///

///

public void removedirectory(string foldername)

catch (exception ex)

}///

/// 獲取當前目錄下明細(包含檔案和資料夾)

///

///

public string getfilesdetaillist()

string line = reader.readline();

//line = reader.readline();

//line = reader.readline();

///

/// 獲取當前目錄下檔案列表(僅檔案)

///

///

public string getfilelist(string mask)

else if (str.trim().substring(0, 1).toupper() == "d")}}

char n = new char ;

return m.split(n);

}///

/// 判斷當前目錄下指定的子目錄是否存在

///

/// 指定的目錄名

public bool directoryexist(string remotedirectoryname)

}return false;

}///

/// 判斷當前目錄下指定的檔案是否存在

///

/// 遠端檔名

public bool fileexist(string remotefilename)

}return false;

}///

/// 建立資料夾

///

///

public void makedir(string dirname)

catch (exception ex)

}///

/// 獲取指定檔案大小

///

///

///

public long getfilesize(string filename)

catch (exception ex)

return filesize;

}///

/// 改名

///

///

///

public void rename(string currentfilename, string newfilename)

catch (exception ex)

}///

/// 移動檔案

///

///

///

public void moviefile(string currentfilename, string newdirectory)

///

/// 切換當前目錄

///

///

/// true 絕對路徑 false 相對路徑

public void gotodirectory(string directoryname, bool isroot)

else

ftpuri = "ftp://" + ftpserverip + "/" + ftpremotepath + "/";

}///

/// 刪除訂單目錄

///

/// ftp 主機位址

/// ftp 使用者名稱

/// ftp 使用者名稱

/// ftp 密碼

public static void deleteorderdirectory(string ftpserverip, string foldertodelete, string ftpuserid, string ftppassword)

}//刪除沖印規格資料夾

fw.gotodirectory(foldertodelete, true);

fw.removedirectory(folder);}}

//刪除訂單資料夾

string parentfolder = foldertodelete.remove(foldertodelete.lastindexof('/'));

string orderfolder = foldertodelete.substring(foldertodelete.lastindexof('/') + 1);

fw.gotodirectory(parentfolder, true);

fw.removedirectory(orderfolder);

}else

}catch (exception ex)}}

public class insert_standard_errorlog

}

FTP檔案上傳

是網上找的例子,原文找不到了。public class ftputils2 return 判斷是否登入成功 public boolean ftplogin else ftp伺服器連線回答 int reply this.ftpclient.getreplycode if ftpreply.isposi...

FTP批量上傳

ftp預設的檔案傳輸方式是基於 ascii 碼的,如果要以二進位制格式傳輸檔案,那麼要先輸入 bin 命令,然後再用 put 或get 命令。1 如果需要傳輸乙個目錄裡的所有檔案,那麼可以使用 mput 或mget 命令來替代 put 或get 命令。注意 需要使用prompt off命令,來關閉互...

ftp檔案上傳

pom依賴引入 commons net commons net 3.3實現 service public class ftpserviceimpl private string ftphost ftp伺服器位址 value private int ftpport ftp伺服器端口 value pri...