cancel
Showing results for 
Search instead for 
Did you mean: 

Illegal characters in ZIP

PeterVígh
Level 4

Greetings,

Is there any way to rename files in ZIP ? 

When we tried to extract from ZIP to Folder we get an error msg : Could not execute code stage because exception thrown by code stage: Illegal characters in path.

Later we found the file, the filename started with the "_" character. Or how can i extract files with special characters in file name? 

One more thing, when we extract from ZIP manually there is no problem, but when with BP it's throwing error msg. Or when the BP successfully extract from ZIP , we get file names like "cn� spr�" ,the original name was "cná sprá". 



------------------------------
Peter Vígh
------------------------------

1 BEST ANSWER

Helpful Answers

Hi Peter,

Sorry for the late reply as I got occupied with some of my personal errands for last few days. As per your requirement, if I am correct you are looking for a way to rename the file entries within the zip file even before extracting the data onto a folder. If that is the requirement, then I think the current utility which Blue Prism has can't be used as 'Utility - Windows Compressed File' uses 'System.IO.Compression' namespace which can't allow to make any changes to the entry names as they are of read only type.

However, you can use the 'DotNetZip' package which can be installed/downloaded from the following Nuget package location: DotNetZip Nuget Package  and copy the highlighted file into Blue Prism installation folder as shown below:

8352.png

8353.png

This DLL internally uses 'System.IO.Compression' and 'Ionic.Zip' utilities. In order to now use it inside Blue Prism, you can create a new object and give it a suitable name. In my case the name of the object is 'Utility - Windows Compressed File Extended' and in the 'Initialise' page, under page description stage you need to add the following 'External References' : DotNetZip.dll and the following 'Namespace Import': Ionic.Zip. Also, ensure that the language chosen is 'Visual Basic' as shown below:

8354.png
Now, add a new action called as 'Rename Zip Entries' and add the below input and output parameters:

Input Parameters:

- Zip File Path (Text) : The file path of the zip file where the modification to the entries need to be performed.

- Entry Names (Collection) : The entry names collection consisting of the original names and the modified names.
      - Original Name (Text) : This field consists of the original name of the file entry inside the zip archive which you want to rename.
      - Modified Name (Text) : This field consists of the name to which the file entry inside the zip archive needs to be renamed into.

Output Parameters:

- Message (Text) : The message text displaying any file entries not being found in the zip archive.

8355.png
Now, add a code stage called 'Rename Zip Entries' with the below parameters:

8356.png

Code:

8357.png

Dim zipFile As ZipFile = ZipFile.Read(Zip_File_Path)
Dim entryExists As Boolean


For Each row As System.Data.DataRow In Entry_Names.Rows

	entryExists = False

	For i = 0 To zipFile.Count-1

		If zipFile(i).FileName.Equals(CStr(row("Original Name"))) Then
	
			zipFile(i).FileName = CStr(row("Modified Name"))
			entryExists = True
			Exit For		
		
		End If

	Next

	'Validate if the entry was not found in the zip file

	If entryExists = False Then
	
		If Message.Equals(String.Empty) Then
		
			Message = "The current zip entry does not exists in the provided zip file path: " + Environment.NewLine() + Environment.NewLine() + CStr(row("Original Name"))

		Else

			Message = Message + Environment.NewLine() + CStr(row("Original Name"))

		End If

	End If

Next


zipFile.Comment = "This archive has been modified at the following date: " + Now.ToString()
zipFile.Save()

Now, you can publish the action and test it from Process Studio. For my test scenario, I have take the below zip file which consists of two file entries - 'Input.xlsx' and 'Split Columns From Excel.bprelease' :

8358.png

8359.png


Now, my input zip file path parameter will have the file path of this zip file whereas the entry names collection parameter will have three entries out of which two rows consists of the valid file names which are available within my zip file and the last row consists of an invalid file entry that does not exists within my zip file as shown below:

8360.png

Now, once I execute the workflow below output is what I get:

8361.png
For the last entry, I got the error message in my message output as it does not exists, however for the other two entries my zip archive looks as below now:

8362.png

This action will help you to rename any file entry within a specified zip file as long as you provide the correct file entry name and the name that needs to be used for renaming the file entry in the proper format as shown above.
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

View answer in original post

4 REPLIES 4

Hello Peter,

Which Utility are you using to unzip files?

------------------------------
If I was of assistance, please vote for it to be the "Best Answer".

Thanks & Regards,
Tejaskumar Darji
Sr. Consultant-Technical Lead
------------------------------

Hi Peter,

I checked the same from the latest DX Exchange asset and it seems to work properly for me but with those special characters which you mentioned:

8348.png

Try downloading the latest asset from here:  Windows Compressed File

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Hello guys,

I tried the updated version of the Windows Compressed File utility, still have the same issue.

So the file name is : _fileName.docx - still getting the same error msg.
Is there any way to change the file name in ZIP? 

Thank you.



------------------------------
Peter Vígh
------------------------------

Hi Peter,

Sorry for the late reply as I got occupied with some of my personal errands for last few days. As per your requirement, if I am correct you are looking for a way to rename the file entries within the zip file even before extracting the data onto a folder. If that is the requirement, then I think the current utility which Blue Prism has can't be used as 'Utility - Windows Compressed File' uses 'System.IO.Compression' namespace which can't allow to make any changes to the entry names as they are of read only type.

However, you can use the 'DotNetZip' package which can be installed/downloaded from the following Nuget package location: DotNetZip Nuget Package  and copy the highlighted file into Blue Prism installation folder as shown below:

8352.png

8353.png

This DLL internally uses 'System.IO.Compression' and 'Ionic.Zip' utilities. In order to now use it inside Blue Prism, you can create a new object and give it a suitable name. In my case the name of the object is 'Utility - Windows Compressed File Extended' and in the 'Initialise' page, under page description stage you need to add the following 'External References' : DotNetZip.dll and the following 'Namespace Import': Ionic.Zip. Also, ensure that the language chosen is 'Visual Basic' as shown below:

8354.png
Now, add a new action called as 'Rename Zip Entries' and add the below input and output parameters:

Input Parameters:

- Zip File Path (Text) : The file path of the zip file where the modification to the entries need to be performed.

- Entry Names (Collection) : The entry names collection consisting of the original names and the modified names.
      - Original Name (Text) : This field consists of the original name of the file entry inside the zip archive which you want to rename.
      - Modified Name (Text) : This field consists of the name to which the file entry inside the zip archive needs to be renamed into.

Output Parameters:

- Message (Text) : The message text displaying any file entries not being found in the zip archive.

8355.png
Now, add a code stage called 'Rename Zip Entries' with the below parameters:

8356.png

Code:

8357.png

Dim zipFile As ZipFile = ZipFile.Read(Zip_File_Path)
Dim entryExists As Boolean


For Each row As System.Data.DataRow In Entry_Names.Rows

	entryExists = False

	For i = 0 To zipFile.Count-1

		If zipFile(i).FileName.Equals(CStr(row("Original Name"))) Then
	
			zipFile(i).FileName = CStr(row("Modified Name"))
			entryExists = True
			Exit For		
		
		End If

	Next

	'Validate if the entry was not found in the zip file

	If entryExists = False Then
	
		If Message.Equals(String.Empty) Then
		
			Message = "The current zip entry does not exists in the provided zip file path: " + Environment.NewLine() + Environment.NewLine() + CStr(row("Original Name"))

		Else

			Message = Message + Environment.NewLine() + CStr(row("Original Name"))

		End If

	End If

Next


zipFile.Comment = "This archive has been modified at the following date: " + Now.ToString()
zipFile.Save()

Now, you can publish the action and test it from Process Studio. For my test scenario, I have take the below zip file which consists of two file entries - 'Input.xlsx' and 'Split Columns From Excel.bprelease' :

8358.png

8359.png


Now, my input zip file path parameter will have the file path of this zip file whereas the entry names collection parameter will have three entries out of which two rows consists of the valid file names which are available within my zip file and the last row consists of an invalid file entry that does not exists within my zip file as shown below:

8360.png

Now, once I execute the workflow below output is what I get:

8361.png
For the last entry, I got the error message in my message output as it does not exists, however for the other two entries my zip archive looks as below now:

8362.png

This action will help you to rename any file entry within a specified zip file as long as you provide the correct file entry name and the name that needs to be used for renaming the file entry in the proper format as shown above.
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.