当前位置: 代码迷 >> C# >> 使用FtpClient批量上传文件解决方法
  详细解决方案

使用FtpClient批量上传文件解决方法

热度:433   发布时间:2016-05-05 05:30:57.0
使用FtpClient批量上传文件
 代码如下:
  foreach (FileInfo file in dir.GetFiles())
                {
                    string s = file.FullName;
                    string ss = remotePath + file.Name;
                    ftpClient.Put(file.FullName, remotePath + "/" + file.Name);
                    
                    MoveFile(file.FullName, ht["BackPath"].ToString()+file.Name);
                    SaveLog("上传文件" + file.Name + "成功!(" + DateTime.Now.ToString() + ")", ht["LogPath"].ToString(), ht["Logext"].ToString());
                }
 catch(Exception e)
            {
                SaveLog("发生错误:" + e.Message, ht["LogPath"].ToString(), ht["Logext"].ToString());
            }
在ftpClient.Put(file.FullName, remotePath + "/" + file.Name);执行这句话时,出现异常,Can't access file. (code=550)。

请大神解决,thanks。
------解决思路----------------------
没权限 put,那么有没有权限下载这个文件呢?
------解决思路----------------------
有可能权限问题
还有文件名是不是中文的,非英文的话要设置编码类型
  相关解决方案