繁体   English   中英

zip文件不支持错误URI格式

[英]zip file Error URI formats are not supported

在这里,我尝试使用dotnetzip压缩目录的内容,并且收到此错误消息不支持URI格式。
这是我用来执行此操作的代码。

string strDirectoryName="http://zyx.blob.core.windows.net/myfiles/mymusic"
       using (ZipFile zip = new ZipFile())
            {
                zip.AddDirectory(strDirectoryName);
                zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
                zip.Save("zipFileToCreate");
            }

在这里调查类似问题的答案。我也遵循相同的url格式,然后为什么会收到此错误。请帮助我解决此错误

我修改了上面的代码,如下所示,并且zip文件已创建但已损坏。 在我的Blob容器“ myfiles”中,我想通过读取myMusic文件夹中的所有文件和文件夹,同时在zip文件中保留相同的文件夹结构,来创建一个名为“ mymusic.zip”的zip文件。以下代码创建了该zip文件,但是zip文件已损坏。是否有解决此问题的建议?

string ofurl = @"http://myxyzstorage.blob.core.windows.net/myfiles/mymusic";
            string ofBlob = @"http://myxyz.blob.core.windows.net/myfiles";
          dBlob = new CloudBlob(blobClient.GetBlobReference(ofBlob));

            using (var zipFile = new ZipFile())
            {
                byte[] fileBytes = dBlob.DownloadByteArray();
                using (var fileStream = new MemoryStream(fileBytes))
                {
                    fileStream.Seek(0, SeekOrigin.Begin);
                    zipFile.AddEntry(ofurl+".zip", fileBytes);
                }
                var sas = offlineContainer.GetSharedAccessSignature(new SharedAccessPolicy()
                {
                    Permissions = SharedAccessPermissions.Write,
                 // SharedAccessExpiryTime = DateTime.UtcNow.AddSeconds(this.timeOutSeconds)
                });

                using (var zipStream = new MemoryStream())
                {
                    zipFile.Save(zipStream);
                    zipStream.Seek(0, SeekOrigin.Begin);
                    var blobRef = ofContainer.GetBlobReference(ofurl);
                    blobRef.UploadFromStream(zipStream);
                }

            }

这里上面有我的代码,为什么我的zip文件已损坏?

该站点看起来既解决了问题又解决了问题。

Cheeso- DotNetZip can read from filesystems. It cannot read from http sources. An easy way to do what you want is to send a GET request to the HTTP resource, and then pass the ResponseStream to the call to AddFile(). DotNetZip can read from filesystems. It cannot read from http sources. An easy way to do what you want is to send a GET request to the HTTP resource, and then pass the ResponseStream to the call to AddFile().

然后,他继续编写示例解决方案

我不熟悉dotnetzip,但我想我知道您的问题。

访问服务器项目时,请使用服务器路径,而不要使用URI(网址)。 操作系统不知道http://your.website实际上是其c:\\\\web\\website\\somedirectory

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM