全部, 我试图在目录中查找文件,将它们压缩成流,然后将它们放在另一个目录中。在压缩文件但我得到意外的归档结束。任何帮助都会很棒。
他们传入
strReport'报告名称
strUser'要搜索的文件夹
strReportNameSearch'要搜索的文件
vstest.console.exe
2018-03-28T22:02:53.9581695Z "C:\A\Default\w\42\a\AppxPackages\EBMSMyTimeHelperTests_1.0.0.0_x86_Unit Tests_Test\EBMSMyTimeHelperTests_1.0.0.0_x86_Unit Tests.appx"
2018-03-28T22:02:53.9581797Z /logger:"trx"
2018-03-28T22:02:53.9581969Z Starting test execution, please wait...
2018-03-28T22:02:53.9582168Z Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\A\Default\w\42\a\AppxPackages\EBMSMyTimeHelperTests_1.0.0.0_x86_Unit Tests_Test\EBMSMyTimeHelperTests_1.0.0.0_x86_Unit Tests.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
答案 0 :(得分:0)
经过大量试验,这个错误有效
使用zf As FileStream = New FileStream(wholezip,FileMode.OpenOrCreate,FileAccess.ReadWrite) '使用zf As FileStream = File.Create(wholezip) '打开拉链流 使用zipOutputStream作为新的ZipOutputStream(zf) zipOutputStream.SetLevel(9)'设置压缩级别 '获取文件 thefiles = Directory.GetFiles(" ReportLookup")。ToString()& strUser,strReportNameSearch&" *",SearchOption.TopDirectoryOnly) '循环文件 对于每个fileName As String在文件中 Dim zentry As ZipEntry = New ZipEntry(Path.GetFileName(fileName)) zentry.IsUnicodeText = True zipOutputStream.PutNextEntry(zEntry是) '计算字节数 使用streamReader作为FileStream = File.OpenRead(fileName) Dim count As Integer = streamReader.Read(buffer,0,buffer.Length) 计数> 0 zipOutputStream.Write(buffer,0,count) count = streamReader.Read(buffer,0,buffer.Length) 结束时 结束使用 下一个 结束使用 结束使用