473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Removing a file path from xml while zipping

maylortaylor
72 64KB
I am trying to read a XML file that will find the location of certain files and then zip them into a directory also located in the XML file. However, as of now, I am copying the entire path of the file where I only want the file itself in the zip. Below is some of the code in question for reference.
Expand|Select|Wrap|Line Numbers
  1. ------ Declarations ------
  2. Sub main()
  3.  
  4.         Dim doc As New System.Xml.XmlDocument
  5.         doc.Load("C:\users\matt taylor\desktop\backup\backup.xml")
  6.         Dim nSource = doc.GetElementsByTagName("Source")
  7.         Dim nDestin = doc.GetElementsByTagName("Destination")
  8.  
  9. ------ outputting the innertext of the 'source' XML tag ----
  10. For Each item As System.Xml.XmlElement In nSource
  11.             Console.WriteLine(item.InnerText)
  12.             myLogger.Log(item.InnerText)
  13.         Next
  14.  
  15. ----- zipping ----
  16. Using zip As New ZipFile()
  17.             For Each item As System.Xml.XmlElement In nSource
  18.                 zip.AddFile(item.InnerText)
  19.             Next
  20.             For Each item As System.Xml.XmlElement In nDestin
  21.                 zip.Save(item.InnerText)
  22.             Next
  23.         End Using

>>>>>>> as you can see from my code, the zip is pulling directly from the inner text of the XML file (which is the full path name of where the file came from). How would I get my zip to just zip the file by itself (no directories)
Nov 20 '12 #1

✓ answered by Rabbit

If you look at the documentation for ionic.dll, the AddFile method has an optional second parameter that allows you to define the directory to use in the archive.
Expand|Select|Wrap|Line Numbers
  1. zip.AddItem(itemPath, "flat")

4 1628
Rabbit
12,516 Expert Mod 8TB
The answer depends on which API you're using to do your zipping. You should read the documentation from whomever wrote the API.
Nov 20 '12 #2
maylortaylor
72 64KB
I'm using Ionic.dll to do my zipping. I feel that i could easily correct this issue if just added a line or two of code that would remove the directory path after it has been added to the zip file index. But seeing as to how i'm only a week into VB, i'm limited on my knowledge.
Nov 20 '12 #3
Rabbit
12,516 Expert Mod 8TB
If you look at the documentation for ionic.dll, the AddFile method has an optional second parameter that allows you to define the directory to use in the archive.
Expand|Select|Wrap|Line Numbers
  1. zip.AddItem(itemPath, "flat")
Nov 20 '12 #4
maylortaylor
72 64KB
Thank you rabbit. That worked perfectly.
Nov 20 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
2
by: Teis Draiby | last post by:
(Using C#) Question 1: Is there an easy build-in support for determining wether a given file path is 1) A valid file path (Only legal characters) 2) The file exists 3) The path exists
3
by: Matt | last post by:
The user can select a file in the file open dialog using <input type="FILE">, but the user can also enter the full file path in the browse text box manually. My question is if there are JavaScript...
10
by: darrel | last post by:
I have an input type="file" field that I am using to accept a file upload. This works, but I'm having problems with the filename property. In firefox, this: MyInputField.postedfile.filename ...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
2
xtianixm
by: xtianixm | last post by:
hola everyone, how can i save a file path into mysql database without removing the '\' im using XAMPP for my database or phpmyadmin then when i try to insert a file path (ex....
0
xtianixm
by: xtianixm | last post by:
hola everyone, how can i save a file path into mysql database without removing the '\' im using XAMPP for my database or phpmyadmin then when i try to insert a file path (ex....
10
by: Raheem | last post by:
Hello, I built a development version of a live website on my hosted account. However the development version is having problems with finding include files. After troubleshooting I was able to...
6
by: starlight849 | last post by:
hello, I am reading all files from a directory and writing them to a text file. This is working just fine. IO.File.WriteAllLines(strFile, IO.Directory.GetFiles(strPath, "*.txt")) How would i go...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.