使用C#在SFTP中提取ZIP文件 [英] Extract ZIP file in SFTP using C#

查看:104
本文介绍了使用C#在SFTP中提取ZIP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SFTP(WinSCP)位置有一个ZIP文件.

I have a ZIP file in SFTP (WinSCP) location.

是否可以使用ACP.NET Core在相同的SFTP位置提取ZIP文件?任何帮助将不胜感激

Is it possible to extract the ZIP file in same SFTP location using ACP.NET Core? Any help would be much appreciated

推荐答案

您不能使用SFTP协议在远程服务器上解压缩文件.那是不可能的.无论您使用哪种语言或库.

You cannot unzip files on remote server using SFTP protocol. That's not possible. No matter what language or libraries do you use.

您也不能使用客户端库来解压缩非本地文件.您将必须下载存档(保存到临时的本地文件或至少保存到内存),解压缩并将解压缩的文件上传回去.那可能不是您想要的.

You cannot use client-side libraries to unzip a non-local file either. You would have to download the archive (to a temporary local file or at least to a memory), extract it and upload the extracted files back. That's probably not what you want.

最好的方法(如果有shell访问权限)是在远程服务器上执行(使用SSH)任何可用命令 进行就地提取.
有关如何使用C#中的SSH.NET库通过SSH执行shell命令的示例,请参见:
C#发送简单的SSH命令.

Best you can do (if you have a shell access) is to execute (using SSH) any available command on the remote server to do the extraction in-place.
For an example how to execute a shell command over SSH using SSH.NET library in C#, see:
C# send a simple SSH command.

有关FTP的一个相关问题:我们是否可以使用C#在FTP服务器中解压缩文件
(答案基本相同–尽管使用SFTP,但与使用FTP相比,您更有可能通过Shell访问)

A related question about FTP: Can we unzip file in FTP server using C#
(with basically the same answer – though with SFTP, it is more likely you have a shell access, than with FTP)

这篇关于使用C#在SFTP中提取ZIP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆