我需要从我的implict ftps服务器下载一个zip文件。这是我尝试下载文件的代码:
public class WiFiDemo extends Activity implements OnClickListener
{
WifiManager wifi;
ListView lv;
TextView textStatus;
Button buttonScan;
int size = 0;
List<ScanResult> results;
String ITEM_KEY = "key";
ArrayList<HashMap<String, String>> arraylist = new ArrayList<HashMap<String, String>>();
SimpleAdapter adapter;
/* Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textStatus = (TextView) findViewById(R.id.textStatus);
buttonScan = (Button) findViewById(R.id.buttonScan);
buttonScan.setOnClickListener(this);
lv = (ListView)findViewById(R.id.list);
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if (wifi.isWifiEnabled() == false)
{
Toast.makeText(getApplicationContext(), "wifi is disabled..making it enabled", Toast.LENGTH_LONG).show();
wifi.setWifiEnabled(true);
}
this.adapter = new SimpleAdapter(WiFiDemo.this, arraylist, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value });
lv.setAdapter(this.adapter);
registerReceiver(new BroadcastReceiver()
{
@Override
public void onReceive(Context c, Intent intent)
{
results = wifi.getScanResults();
size = results.size();
}
}, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
}
public void onClick(View view)
{
arraylist.clear();
wifi.startScan();
Toast.makeText(this, "Scanning...." + size, Toast.LENGTH_SHORT).show();
try
{
size = size - 1;
while (size >= 0)
{
HashMap<String, String> item = new HashMap<String, String>();
item.put(ITEM_KEY, results.get(size).SSID + " " + results.get(size).capabilities);
arraylist.add(item);
size--;
adapter.notifyDataSetChanged();
}
}
catch (Exception e)
{ }
}
}
在这个程序中,我能够登录到我的ftps服务器,并且能够找到其中存在的文件。但是,当我尝试通过import sys
import chilkat
ftp = chilkat.CkFtp2()
# Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial")
if (success != True):
print(ftp.lastErrorText())
sys.exit()
# If this example does not work, try using passive mode
# by setting this to True.
ftp.put_Passive(False)
ftp.put_Hostname("hostip")
ftp.put_Username("username")
ftp.put_Password("password")
ftp.put_Port(990)
# We don't want AUTH SSL:
ftp.put_AuthTls(False)
# We want Implicit SSL:
ftp.put_Ssl(True)
# Connect and login to the FTP server.
success = ftp.Connect()
if (success != True):
print(ftp.lastErrorText())
sys.exit()
else:
# LastErrorText contains information even when
# successful. This allows you to visually verify
# that the secure connection actually occurred.
print(ftp.lastErrorText())
print("FTPS Channel Established!")
#clearing the control channel
success = ftp.ClearControlChannel()
if (success != True):
print(ftp.lastErrorText())
sys.exit()
else:
print(ftp.lastErrorText())
ftpResponse = ftp.feat()
fileSize = ftp.GetSizeByName("15_20.zip")
if (fileSize < 0):
print("file does not exist")
else:
print("file exists and is " + str(fileSize) + " bytes in size")
ftp.put_RestartNext(True)
localFilename = "C://mcx5min//14_40.zip" # copy the path from the old mcx.py
remoteFilename = "14_40.zip"
success = ftp.GetFile(remoteFilename, localFilename)
if (success != True):
print(ftp.lastErrorText())
sys.exit()
ftp.Disconnect()
函数下载文件时,会抛出类似&#34; GetFile()
&#34;的错误。我不确切地知道本地使用Windows服务器的错误是什么。我真的很新。所以请任何人帮我解决这个问题。