[2008] Reordering [UNRESOLVED]
I am using Microsoft.Web.Administration to create NEW websites programatically.
How do i change all ID's starting from zero? Currently i have about 100 websites and they are ordered like following:
1, 2, 4, 18, 200, 1234, 232324, 2455344 etc. etc.
And i want them ordered like this: 1, 2, 3, 4, 5, 6, 7, ... etc. up to 100.
This question doesn't have to refer IIS and the Administration class directly.
I just need to change the id like you change the values into database or array/arraylist or generic list.
Means the value with 1234 should be 6 if six is not already taken or 18 should be 3 etc.
Thanks
Re: [2008] Reordering [UNRESOLVED]
Hmm for some reason the code below won't work as expected.
Code:
Dim intList As List(Of Integer) = New List(Of Integer)
For Each site As Site In sites
intList.Add(site.Id)
Next
intList.Sort()
Dim i As Integer = 1
For Each item As Integer In intList
If i <> item And Not intList.Contains(i) Then
For Each sit As Site In sites
If item = sit.Id Then
sit.Id = i
serverMgr.CommitChanges()
i += 1
End If
Next
End If
Next
Am i missing something? It seems that intList.Contains(i) always return true while it shouldn't.