저는 안드로이드에서 FTP 클라이언트를 사용하여 안드로이드에서 Wifi로 연결된 로컬 네트워크에 텍스트 파일을 업로드하기 위해 ftp4j 라이브러리를 사용하고 있습니다.Android FTP ChangeDirectory가 실패했습니다.
메신저 디렉토리를 변경하지 않으면 다음 기본 디렉토리는 storage/emulated/0
입니다하지만 client.changeDirectory(Environment.getExternalStorageDirectory().getPath())
를하려고하면 그것은 "디렉토리를 변경하는 데 실패"예외를 잡는다. DCIM, 다운로드, 블루투스 폴더와 같은 외부 폴더 디렉토리에서 파일을 업로드하고 싶습니다. (PC에서 안드로이드를 탐색 할 때처럼).
public void uploadFile(File fileName){
FTPClient client = new FTPClient();
try {
client.connect(ftpHostname);
client.login(ftpUsername, ftpPassword);
client.setType(FTPClient.TYPE_BINARY);
//client.changeDirectory(Environment.getExternalStorageDirectory().getPath());
client.upload(fileName);
notification = "The File Has Been Uploaded";
} catch (Exception e) {
Log.e("UploadFTP", e.toString());
notification = "Upload File Failed";
try {
client.disconnect(true);
} catch (Exception e2) {
Log.e("UploadFTPDC", e2.toString());
}
}
}
편집 :
내가 그렇게 디렉토리를 변경할 필요를 /storage/emulated/0/
을 반환하지 않습니다) 내가 getExternalStorageDirectory을 (로그인 한 후, 자신에게 혼란 스러워요 것 같다.
11-14 10:59:24.936: E/UploadFTP(1764): it.sauronsoftware.ftp4j.FTPException [code=553, message= Could not create file.]