티스토리 뷰
private void UploadFile()
{
//excel 생성.
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://000.000.000.000/up_gmkt_get_delivery_driver_list.sql");
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("your id", "your password");
Stream ftpStream = request.GetRequestStream();
FileStream fs = File.OpenRead(@"D:\7E\up_gmkt_get_delivery_driver_list.sql");
// Copy the contents of the file to the request stream.
byte[] fileContents = new byte[1024];
double total = (double)fs.Length;
int byteRead = 0;
double read = 0;
do
{
byteRead = fs.Read(fileContents, 0, 1024);
ftpStream.Write(fileContents, 0, byteRead);
read += (double)byteRead;
double percentage = read / total * 100;
}
while (byteRead != 0);
fs.Close();
ftpStream.Close();
}
private void DownloadFile()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://000.000.000.000/download/up_gmkt_get_delivery_driver_list.sql");
request.Credentials = new NetworkCredential("your id", "your password");
request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebRequest request1 = (FtpWebRequest)WebRequest.Create("ftp://000.000.000.000/download/up_gmkt_get_delivery_driver_list.sql");
request1.Credentials = new NetworkCredential("your id", "your password");
request1.Method = WebRequestMethods.Ftp.GetFileSize;
FtpWebResponse response = (FtpWebResponse)request1.GetResponse();
double total = response.ContentLength;
response.Close();
FtpWebRequest request2 = (FtpWebRequest)WebRequest.Create("ftp://000.000.000.000/download/up_gmkt_get_delivery_driver_list.sql");
request2.Credentials = new NetworkCredential("your id", "your password");
request2.Method = WebRequestMethods.Ftp.GetDateTimestamp;
FtpWebResponse response2 = (FtpWebResponse)request2.GetResponse();
DateTime modify = response2.LastModified;
response2.Close();
Stream ftpStream = request.GetResponse().GetResponseStream();
FileStream fs = new FileStream(@"D:\CJFtp\up_gmkt_get_delivery_driver_list.sql", FileMode.Create);
byte[] fileContents = new byte[1024];
int byteRead = 0;
double read = 0;
do
{
byteRead = ftpStream.Read(fileContents, 0, 1024);
fs.Write(fileContents, 0, byteRead);
read += (double)byteRead;
double percentage = read / total * 100;
}
while (byteRead != 0);
ftpStream.Close();
fs.Close();
}
Can't connect to FTP: (553) File name not allowed : 오류 발생시 아래와 같이 코드를 수정
FtpWebRequest request =
linux ftp server
(FtpWebRequest)WebRequest.Create(@"ftp://000.00.000.000//users/interface/00eai_test/qxpress/rcvdat/SR3012081920181005110130.txt");
window ftp server
(FtpWebRequest)WebRequest.Create(@"ftp://000.00.000.000/users/interface/00eai_test/qxpress/rcvdat/SR3012081920181005110130.txt");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("your id", "your password");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;
Stream ftpStream = request.GetRequestStream();
ftpStream.Write(Encoding.Default.GetBytes(stringBuilder.ToString()), 0, Encoding.Default.GetBytes(stringBuilder.ToString()).Length);
if (ftpStream != null) { ftpStream.Close(); }
- Total
- Today
- Yesterday
- system.io
- jstl(java standard tag library)
- React
- await
- 특정 문자를 기준으로 자르기
- java-개발 환경 설정하기
- 표현 언어(expression language)
- 문자 자르기
- .submit()
- 스프링 시큐리티(spring security)
- 제품 등록
- nl2br
- REST API
- 인텔리제이(intellij)
- 스프링 프레임워크(spring framewordk)
- java.sql
- 람다식(lambda expression)
- System.Diagnostics
- In App Purchase
- 스프링 시큐리티(spring security)-http basic 인증
- error-java
- 상품 등록
- 스프링 프레임워크(spring framework)
- jstl(java standard tag library)-core
- jsp 오픈 소스
- 메이븐(maven)
- MainActor
- java web-mvc
- 진수 변환
- java 키워드 정리
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |