我正在使用Renci SSH.Net,如果我使用c# .net SSH.Net,是否可以删除ZIP文件中的文件名?
发布于 2020-09-24 06:27:21
我认为你不能直接删除sftp服务器中这个zip文件中的文件。但是您可以将此压缩文件下载到本地临时目录,然后可以在此本地临时目录中使用delete files。修改后,您可以将此zip文件上传到您的服务器。
代码取自上面的链接( Denis Radinski编写):
using (FileStream zipToOpen = new FileStream(@"C:\Users\Desktop\app.zip", FileMode.Open))
{
using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
{
foreach (var item in archive.Entries)
{
if (item.Name.Equals("test.txt"))
{
item.Delete();
break; //needed to break out of the loop
} // if
} // foreach
} // using
} // using
您需要引用System.IO.Compression.dll
。
https://stackoverflow.com/questions/64040535
复制相似问题