i have a RadUpload that uploads zip file only, so i want to rename the each file during Extraction Process, i tried a way :
Protected Sub Upload(sender As Object, e As EventArgs)
Dim extractPath As String = Server.MapPath("~/temp/")
Dim file1 As String = RadUpload1.UploadedFiles(0).FileName
ExtractFileToDirectory(file1, extractPath)
End Sub
Public Sub ExtractFileToDirectory(zipFileName As String, outputDirectory As String)
Dim zip As ZipFile = ZipFile.Read(outputDirectory & zipFileName)
Directory.CreateDirectory(outputDirectory)
For Each e As ZipEntry In zip
Dim NewName As String = Now().ToString("ddMMyyhhmmss")
Dim newext As String = ".jpg"
e.FileName = NewName + newext
e.Extract(outputDirectory, ExtractExistingFileAction.OverwriteSilently)
Next
End Sub
at the first it will rename and extract the first file but then gives this error:
[ It has been adjusted Group: Could not execute the census process. ]
any idea?
It seems there is a problem with
outputDirectoryIn the first line you are trying to read
outputDirectory & zipFileName, in the second line you are trying to create that path.See MSDN, your code should be similar to
NOTE: Using
"ddMMyyhhmmss"as a file name you most likely will get an error if unzip takes less than 1 sec - either add ms, i.e."ddMMyyhhmmssfff"or check if file name does not exist before extract.