< návrat zpět

MS Excel


Téma: VS: Ako prepisat XML subor v ZIP subore? rss

Zaslal/a 12.4.2016 15:38

Ahojte,

zas mam problem :)

uz som zistil:
- ako sa da otvorit zip subor
- ako zo zipka si setnut subor a pracovat s nim
- tak isto ako ziskavat udaje zo subora

jediny problem mam ze netusim ako taky subor prepisat

tu je kod na prepisovanie ale robi duplicitu:
Imports System.Xml
Dim zipPath As String = "test.pptx"
Dim entry As ZipArchiveEntry = Nothing
Dim doc As XmlDocument = New XmlDocument

Using zipToOpen As FileStream = New FileStream(zipPath, FileMode.Open)
Using archive As ZipArchive = New ZipArchive(zipToOpen, ZipArchiveMode.Update)
aGetThumbnail = Image.FromStream(archive.GetEntry("docProps/thumbnail.jpeg").Open)

entry = archive.GetEntry("docProps/core.xml")
Using stmZip As Stream = entry.Open
doc.Load(stmZip)
doc.Item("cp:coreProperties").Item("dc:title").InnerText = "test"
doc.Save(stmZip)
End Using
End Using
End Using


neviete kde robim chybu???

Zaslat odpověď >

#031110
avatar
este priloha:
Příloha: zip31110_test.zip (20kB, staženo 26x)
citovat
#031117
avatar
tak uz som to vyriesil :)

treba si vytvorit jednu entry na vymazanie a druhu entry na zapisovanie a potom to pojde :)

mozno niekto ma lepsie riesenie al ja osobne som ine nenasiel

tu je priklad:
Dim zipPath As String = "test.pptx"
Dim entry As ZipArchiveEntry = Nothing
Dim entry2 As ZipArchiveEntry = Nothing
Dim doc As XmlDocument = New XmlDocument

Using zipToOpen As FileStream = New FileStream(zipPath, FileMode.Open)
Using archive As ZipArchive = New ZipArchive(zipToOpen, ZipArchiveMode.Update)
entry = archive.GetEntry("docProps/core.xml")
Using stmZip As Stream = entry.Open
doc.Load(stmZip)
doc.Item("cp:coreProperties").Item("dc:title").InnerText = "test"
End Using

entry2 = archive.CreateEntry("docProps/core.xml")
entry.Delete()
Using stmZip As Stream = entry2.Open
doc.Save(stmZip)
End Using
End Using
End Using
citovat

Uživatelské menu

Nejste přihlášen(a)
avatar\n

Menu

On-line nástroje

Formulář Faktura

Formulář Faktura IV

Oblíbený formulář Faktura byl vylepšen a rozšířen.
Více se dočtete zde.

Aktivní diskuse

Čas od do

lubo • 19.4. 16:30

Makro smyčka

MilanKop • 19.4. 10:46

Makro smyčka

elninoslov • 19.4. 9:02

Čas od do

elninoslov • 19.4. 8:46

Čas od do

jarek1111 • 18.4. 13:46

Čas od do

lubo • 18.4. 11:13

Čas od do

jarek1111 • 18.4. 8:32