During the lifetime of the workflow instance (which may be years, but more often is several months) this folder is used to view documents associated with the workflow, including an updated version of the xml each time the form is updated.
In the last activity of the workflow, when the process instance is completed, we are trying to move the folder that was created into a folder named 'Completed' at the same heirarchical level.
I'm using CreateFolder in the first activity, then again in the last event of the last activity to first create the working folder, then the completed folder then the subfolder (named the same as the working folder).
If Not SpsList.CreateFolder(Site, Division & "Completed", ErrMsg) Then
Console.WriteLine("------- Could not create folder " & Division & "Completed due to the following error:" & ErrMsg)
Else
Console.WriteLine("------- Folder " & Division & "Completed Created.")
End If
If Not SpsList.CreateFolder(Site, Division & "Completed/" & Folder, ErrMsg) Then
Console.WriteLine("------- Could not create folder " & Division & "Completed/" & Folder & " due to the following error:" & ErrMsg)
Else
Console.WriteLine("------- folder " & Division & "Completed/" & Folder & " Created.")
End If
Then I loop thru the files in the working folder, copying each one to the folder under 'Completed/' of the same name, finally deleting it from the source folder:
For Each sFile In spsList.GetFolderFiles(Server, Site, Division & Folder, ErrMsg)
If sFile = "" Then Goto NextFile
If Not spsList.UpLoadDocument (Server, Site, Division & "Completed/" & Folder, sFile, oByte, True, ErrMsg) Then
Console.WriteLine("------- Could not upload document due to the following error:" & ErrMsg)
Else
'delete file
If Not spsList.DeleteDocument(Site, Division & Folder, sfile, ErrMsg) Then
Console.WriteLine("------- Could not delete the document due to the following error:" & ErrMsg)
Else
Console.WriteLine("------- File " & Division & Folder & "/" & sFile & " deleted ...")
End If
End If
NextFile:
Next
All of this works fine, and at this point the source folder is empty.
Now comes the problem: The DeleteFolder method has the same arguments as the CreateFolder method, so I follow the above code with:
If Not spsList.DeleteFolder(Site, Division & Folder, ErrMsg) Then
Console.WriteLine("------- Could not delete folder " & Site & Division & Folder & " due to the following error:" & ErrMsg)
Else
Console.WriteLine("------- Folder " & Division & Folder & " deleted ...")
End If
I invariably get the error "Value does not fall within the expected range."
I'm at a dead end - can anyone help on this?