FTP client : How to change working directory

by Guru » Fri, 23 Apr 2010 08:02:05 GMT


Sponsored Links
 Hi friends,
I am beginner to android. I am trying to develop FTP client in
android. I am unable to change the working directory.
I am using FileZilla FTP server.
I want to upload one file (samplefile.txt) to FTP server. So,

Step 1: I created this file using
FileOutputStream fOut =
openFileOutput("samplefile.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(TESTSTRING);
osw.flush();
osw.close();

and I confirmed this file got created in "/data/data/com.xyz.Hello/
files/samplefile.txt"

Step 2: open and connect to ftp server

ftp.connect("107.108.yy.xx", 4000);
ftp.login(username, password);
ftp.setFileType(FTP.ASCII_FILE_TYPE);
ftp.port(ftp.getRemoteAddress(), ftp.getRemotePort());

Step 3: Store samplefile.txt in FTP server

{
InputStream input;
                                String path = new
java.io.File(".").getCanonicalPath();
                                Log.i("FTP", path);
                                input = new FileInputStream("samplefile.txt");

                                ftp.storeFile(ftp.printWorkingDirectory(),
input);

                                input.close();
}

Problem: In the step 3, when I do  String path = new
java.io.File(".").getCanonicalPath(); I am getting root directory "/".
But my file is in "/data/data/com.xyz.Hello/files/samplefile.txt". So
I should do change working directory to "/data/data/com.xyz.Hello/
files". But I am not getting how to do this in android? Please help me
to know how to change the working directory. and also let me know if
there is any code help on creating FTP on android.

--



Other Threads

1. Market API based on new website

Now that the market has a website it should be much easier to access
meta information about apps by crawling the web page. Has anybody
already investigated this issue?

Best
Matthias

-- 

2. Temperature Normal SGS

Dear Member, berapa derajat temperatur normal utk SGS soalnya saya
punya bisa sampai 42 derajat Celcius. Info tambahan saya pakai rom
Darky's 9.1 extreme edition

-- 
===============

3. [Closed]: [Need Help/WTA] Motorola Service Center di Area Surabaya. Motorola Defy Matot setelah flash dengan RSD Lite

4. Map Jakarta

5. [Need Help/WTA] Motorola Service Center di AreaSurabaya. Motorola Defy Matot setelah flash dengan RSD Lit

6. Dynamic array ListView problem

7. How to tell in code the orientation