Sourcesafe automation in VB.Net

  • Thread starter Thread starter Chris Dunaway
  • Start date Start date
C

Chris Dunaway

I am trying to call the Get method on the VSSItem object for a specific
file, but I keep getting an COMException that includes:

Additional information: This command only works on projects.

According to the docs:

"The Get method may be called against both file and project objects. When
called against a project, all files in the project are gotten regardless of
their CheckOut status."

Here's the code I am using. v is a VSSItem object that points at the SS
project I am working with. The exception occurs on the Get method:

For Each i In v.Items
If i.Type = VSSItemType.VSSITEM_FILE Then
i.Get(i.LocalSpec, VSSFlags.VSSFLAG_REPSKIP)
End If
Next

Does anyone have an example of code that can show me how to get the latest
version of a file, not a project? I do not want to check it out, just get
the latest version.

Thanks,
 
Chris,

Do you want the file in ur system? if so, pass a reference to the path as
the 1st param in Get():

VSSItem.Get(ref targetFolder,0)

Hope that helps.
 
Chris,

Do you want the file in ur system? if so, pass a reference to the path as
the 1st param in Get():

VSSItem.Get(ref targetFolder,0)

Hope that helps.

Thanks for the response. I have changed the code to the following. That
seemed to have resolved my first problem, now I am encountering another.
When this code runs, every file returns an exception "Version Not Found".

HOWEVER: If I step through the code in debug mode, it doesn't!!!!! Just
running the code I get the exception, but stepping through the code line by
line, NO EXCEPTIONS!!??!!

Any thoughts on that one?

Private Sub GetLatestFiles(ByVal prj As VSSItem)
Dim i As VSSItem

For Each i In prj.Items
If i.Type = VSSItemType.VSSITEM_FILE Then
pbProgress.Increment(1)
Try
i.Get(i.Parent.LocalSpec & "\" & i.Name,0)
Catch ex As COMException
Debug.WriteLine("Error getting file: " & ex.Message)
End Try
pbProgress.Update()
sbStatus.Update()
Else
sbpFile.Text = "Getting " & i.Name
pbProgress.Update()
sbStatus.Update()
GetLatestFiles(i)
End If
Next
End Sub
 
Back
Top