hive读取ftp文件
‘壹’ VB中怎么写,打开之后就进入一个ftp,自动输入密码。读取到FTP上的文件
添加一个部件“Microsoft Internet Transfer Control”然后在窗体上添加一个此对象“Inet1”,设置属性Protocol:2-icFTPRemoteHost:你的FTP服务器IPUsername:你的用户名Password:你的密码 然后再用相关FTP命令读取服务器中的文件.
‘贰’ 如何用FTP获取文件
如果是通过命令行交互式的:
1.
ftp
server_ip
2.
提示输入用户名:输入你的ftp用户名
3.
提示输入密码:输入ftp用户的密码
4.
切换为bin模式:b或者bin命令
5.
用get命令接完整文件名:get
your_file
6.
用wget+通配符模式获取多个文件:wget
*.txt
7.
退出ftp:bye
‘叁’ 访问ftp文件 出现乱码怎么办
1、打开Serv-U 8.0控制台,点击限制和设为域配置高级FTP命令设置和行为,在FTP设置中找到OPTS UTF8命令,右击禁用此命令。再点击下面的全局属性;
‘肆’ FTP怎么读取一个特定目录文件
楼主您好,您可以把ftp用户的家目录设置为你需要读取的目录,然后不然其跳出自己的家目录。这样您一连接ftp就进入您需要读取的目录了。
‘伍’ 我可以直接读取ftp上的文件吗
正常情况下是不能够的,只有你登录ftp后,将文件下下来后才能访问。
‘陆’ 求一段可以读取FTP一个文件夹下面当天更新数据的文件 ,c#写的代码
#region 下载文件
/**//// <summary>
/// 从FTP服务器下载文件,使用与远程文件同名的文件名来保存文件
/// </summary>
/// <param name="RemoteFileName">远程文件名</param>
/// <param name="LocalPath">本地路径</param>
public bool DownloadFile(string RemoteFileName, string LocalPath)
{
return DownloadFile(RemoteFileName, LocalPath, RemoteFileName);
}
/**//// <summary>
/// 从FTP服务器下载文件,指定本地路径和本地文件名
/// </summary>
/// <param name="RemoteFileName">远程文件名</param>
/// <param name="LocalPath">本地路径</param>
/// <param name="LocalFilePath">保存文件的本地路径,后面带有"\"</param>
/// <param name="LocalFileName">保存本地的文件名</param>
public bool DownloadFile(string RemoteFileName, string LocalPath, string LocalFileName)
{
byte[] bt = null;
try
{
if (!IsValidFileChars(RemoteFileName) || !IsValidFileChars(LocalFileName) || !IsValidPathChars(LocalPath))
{
throw new Exception("非法文件名或目录名!");
}
if (!Directory.Exists(LocalPath))
{
throw new Exception("本地文件路径不存在!");
}
string LocalFullPath = Path.Combine(LocalPath, LocalFileName);
if (File.Exists(LocalFullPath))
{
throw new Exception("当前路径下已经存在同名文件!");
}
bt = DownloadFile(RemoteFileName);
if (bt != null)
{
FileStream stream = new FileStream(LocalFullPath, FileMode.Create);
stream.Write(bt, 0, bt.Length);
stream.Flush();
stream.Close();
return true;
}
else
{
return false;
}
}
catch (Exception ep)
{
ErrorMsg = ep.ToString();
throw ep;
}
}
/**//// <summary>
/// 从FTP服务器下载文件,返回文件二进制数据
/// </summary>
/// <param name="RemoteFileName">远程文件名</param>
public byte[] DownloadFile(string RemoteFileName)
{
try
{
if (!IsValidFileChars(RemoteFileName))
{
throw new Exception("非法文件名或目录名!");
}
Response = Open(new Uri(this.Uri.ToString() + RemoteFileName), WebRequestMethods.Ftp.DownloadFile);
Stream Reader = Response.GetResponseStream();
MemoryStream mem = new MemoryStream(1024 * 500);
byte[] buffer = new byte[1024];
int bytesRead = 0;
int TotalByteRead = 0;
while (true)
{
bytesRead = Reader.Read(buffer, 0, buffer.Length);
TotalByteRead += bytesRead;
if (bytesRead == 0)
break;
mem.Write(buffer, 0, bytesRead);
}
if (mem.Length > 0)
{
return mem.ToArray();
}
else
{
return null;
}
}
catch (Exception ep)
{
ErrorMsg = ep.ToString();
throw ep;
}
}
#endregion
‘柒’ c# 如何读取ftp上的text文件
使用Inet控件进行FTP操作
Inet1.Protocol = icFTP
Inet1.RemoteHost = p_ServerName ' 服务器IP或者域名
Inet1.RemotePort = CInt(p_ServerPort) 'FTP端口
Inet1.UserName = uName 'FTP帐号
Inet1.Password = uPWS 'FTP密码
Inet1.Execute "", "ls"
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
vd = Inet1.GetChunk(1024, icString)
判断服务的FTP是否连接成功
下面下载服务器上的text数据,假设文件名为1.txt
p_pathDir 为当前软件运行目录,后面一个字符自带 \,如e:\1111\
tepFile 临时文件
工作方式是先下载这个文件下为,然后判断本地是否存在,如果存在,则打开文件读取内容,如果不存在,则说明服务器上不存在这个文件,但要注意,如果文件过大的话,可能需要等待的时候比较长。
tepFile = p_pathDir & "1.txt_"
'Inet1.Execute hDir, "get 1.txt " & tepFile
Inet1.Execute "", "GET 1.txt " & tepFile
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
If Dir(tepFile) = "" Then
Inet1.Cancel
MsgBox "文件不存在" & InetState, vbOKOnly + vbExclamation, "系统提示"
Else
Inet1.Cancel
'这里已经存在,与本地操作文件一样,请打开获取内容,不再详细写出
'
End If
‘捌’ FTP 读txt文件 。c#
这个没尝试过,但你可以通过Stream这个对象来考虑,通过一段一段的读取,之后再转成字符串,查找你想要的字符串内容。如果知道你所要的字符串所在的位置可能会更快。
FtpWebRequest request = null; //创建对象
request .Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = request .GetResponse() as FtpWebResponse;
Stream stream = response .GetResponseStream();
之后对stream进行读取,读取后是byte数组,再将byte数组,按照字符编码转成字符串应该就可以了。
‘玖’ 易语言 ftp读取txt
步骤是,1.连接FTP服务器进行下载你要的文本文件到本地
2.再打开本地读入文件内容显示在编辑框内
具体例:
.版本 2
.支持库 internet
.支持库 shell
.子程序 __启动窗口_创建完毕
.局部变量 文件号, 整数型
连接FTP服务器 (“58.222.184.**”, “j***”, “0910228***”, , )
FTP文件下载 (“1.txt”, 取特定目录 (3) + “\1.txt”, )‘因为我的E不好编辑,我把他存在桌面了!你可以自己设定位置。
文件号 = 打开文件 (取特定目录 (3) + “\1.txt”, , )
编辑框1.内容 = 读入文本 (文件号, )
‘拾’ c++如何读取ftp上指定的文件
#include<fstream>
using namespace std;
ifstream cin(""/*ftp地址*/);
int main()
{
int a;
cin>>a;
cin.close();
return 0;
}