I have created a project in vb.net that saves a Solid Edge assembly in multiple formats and then zips those formats individually and deletes the unzipped files from the directory. Until very recently, the program was working fine. Now, however, the files are not zipped in the directory. All that happens is that a file with the extension .7z is created one level up (ie I want files to be zipped in C:\Folder\New Folder but the .7z file is created in C:\Folder). Here is some of the project code:
' The extensions are stored in the INI file and must be retrieved
Extension = GetIniValue("CADMakros", "FileFormatExtensions3D", "C:\Windows\RTSettings.INI")
' Checks if there are extensions in the INI file
If Extension = "" Or Extension = " " Then
MsgBox("Keine Erweiterungen in «RTSettings.ini» eingetragen")
Exit Sub
End If
' The extensions are separated by a ";" in the INI file
' Therefore, they are split up into separate strings and sorted in the NewExtensions array
'The NewExtensions array does not have a defined size so that an arbitrary number of extensions can be added to the INI file
NewExtensions = Extension.Split(";")
' The spaces are removed from the extension strings
For i = 0 To UBound(NewExtensions)
NewExtensions(i) = NewExtensions(i).Replace(" ", "")
Debug.Print(NewExtensions(i))
Next
' An array containing the filenames is created whose size is dependent on the number of extensions
' Therefore, the array size changes when the INI file is modified
Dim NewFileNames(NewExtensions.Count) As String
Dim zippedFileNames(NewFileNames.Length) As String
' Remove solid edge extension
FileName = Microsoft.VisualBasic.Left(FileName, InStrRev(FileName, ".") - 1)
' Uses the file name as a default response for the input box
FileName1 = InputBox("Dateinamen eingeben", DefaultResponse:=FileName)
If FileName1 = " " Then
MsgBox("Bitte Dateinamen eingeben")
Exit Sub
ElseIf FileName1 = "" Then
Exit Sub
End If
ProgressBar1.Value = 30
' Creates a new file name that acts as the path of the file
For k = 0 To (NewExtensions.Length - 1)
NewFileNames(k) = ChosenFile & "\" & FileName1 & NewExtensions(k)
Next
' The files are saved
For k = 0 To (NewFileNames.Count - 2)
objDocument.SaveAs(NewFileNames(k))
' The progress of the program is sent to the backgroundWorker so it can update the progress bar accordingly
BackgroundWorker1.ReportProgress(30 + (k / (NewFileNames.Count - 2)) * 65)
' The program must be given time to update the progress bar
System.Threading.Thread.Sleep(200)
Next
For j = 0 To NewFileNames.Length - 2
For i = 0 To UBound(NewExtensions)
If NewFileNames(j).Contains(NewExtensions(i)) Then
zippedFileNames(j) = NewFileNames(j).Substring(0, NewFileNames(j).Length - NewExtensions(i).Length)
zippedLocation(j) = zippedFileNames(j) + "-" + NewExtensions(i).Substring(1)
End If
Next
Next
' The files are zipped
Shell(zipPath & " a " & zippedLocation(0) & ".zip " & NewFileNames(0))
Shell(zipPath + " a " + zippedLocation(1) + ".zip " + NewFileNames(1))
Shell(zipPath + " a " + zippedLocation(2) + ".zip " + NewFileNames(2))
'Dim save As New ProcessStartInfo(zipPath)
'save.Arguments = zipPath & " a -tzip " & zippedLocation(0) & ".zip " & NewFileNames(0)
'Process.Start(save)
' The program is given time to zip the file before it is deleted (this ensures the zipped file contains the required information)
Thread.Sleep(2000)
''The unzipped file is deleted from the computer
My.Computer.FileSystem.DeleteFile(NewFileNames(0))
My.Computer.FileSystem.DeleteFile(NewFileNames(1))
My.Computer.FileSystem.DeleteFile(NewFileNames(2))
ProgressBar1.Value = 100
The zip command is near the bottom (they are shell commands). Sorry about the message box messages, they're in German because I'm doing this for a German company. Thank you in advance!