View Full Version : مسیرآنلاین فایل ها
ashkan_gorg
پنج شنبه 22 اسفند 1392, 16:11 عصر
من توی سرورم مقداری فایل دارم که با وارد کردن آدرس اون میتونم نام فایل ها رو ببینم حالا اگه بخوام توی برنامم اونها رو نمایش بدم بایدچکار کنم،یعنی توی گوشی فایل های داخل سرورم ببینم.لیست ftp
با تشکر
smemamian
شنبه 24 اسفند 1392, 00:53 صبح
با تابع زیر این کار رو انجا بده :
FTPFile[] ftpDirs = mFTPClient.listDirectories();
for (int i = 0; i < ftpDirs.length; i++) {
toppath = ftpDirs[0].getName();
Log.d("Test", "Your Directories : "
+ ftpDirs[i].getName());
}
FTPFile[] ftpdirs2 = mFTPClient.listFiles(toppath);
for (int i = 0; i < ftpdirs2.length; i++) {
Log.d("CONNECT",
"File : " + ftpdirs2[i].getName());
}
فراموش نکنی :
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
ashkan_gorg
شنبه 24 اسفند 1392, 10:14 صبح
تشکر از پاسختون ولی من میخوام فایلی رو از توی اینترنت که روی سرور شخصیم وجود داره توی برنامم نمایش بدم یعنی با واردن کردن آی پی یا نام سایت،نام کاربری ftp و رمز عبور ftp این کار انجام بدم.
_behnam_
یک شنبه 25 اسفند 1392, 00:03 صبح
سلام دوست عزیز و بررسی کنید سایت های زیر رو
سایت اول (http://stackoverflow.com/questions/7053513/howto-do-a-simple-ftp-get-file-on-android)
سایت دوم (http://www.example-code.com/android/ftp_download.asp)
ashkan_gorg
یک شنبه 25 اسفند 1392, 10:32 صبح
من دستورات زیر را گذاشتم library رو هم اضافه کردم ولی خطاش متوجه نمیشم
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
String outStr = "";
CkFtp2 ftp = new CkFtp2(); ((((((ازاین خط ایراد میگیره)))))
boolean success;
// Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial");
if (success != true) {
outStr += ftp.lastErrorText() + "\n";
tv.setText(outStr);
setContentView(tv);
return;
}
ftp.put_Hostname("ftp.example-code.com");
ftp.put_Username("myLogin");
ftp.put_Password("myPassword");
// The default data transfer mode is "Active" as opposed to "Passive".
// Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
outStr += ftp.lastErrorText() + "\n";
tv.setText(outStr);
setContentView(tv);
return;
}
// Change to the remote directory where the file is located.
// This step is only necessary if the file is not in the root directory
// for the FTP account.
success = ftp.ChangeRemoteDir("junk");
if (success != true) {
outStr += ftp.lastErrorText() + "\n";
tv.setText(outStr);
setContentView(tv);
return;
}
// Download a file.
String localFilename;
localFilename = "c:/temp/hamlet.xml";
String remoteFilename;
remoteFilename = "hamlet.xml";
success = ftp.GetFile(remoteFilename,localFilename);
if (success != true) {
outStr += ftp.lastErrorText() + "\n";
tv.setText(outStr);
setContentView(tv);
return;
}
ftp.Disconnect();
outStr += "File Downloaded!" + "\n";
tv.setText(outStr);
setContentView(tv);
}
static {
// Important: Make sure the name passed to loadLibrary matches the shared library
// found in your project's libs/armeabi directory.
// for "libchilkat.so", pass "chilkat" to loadLibrary
// for "libchilkatemail.so", pass "chilkatemail" to loadLibrary
// etc.
//
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.