I'm trying to create a new work item for TFS 2010 via the client SDK.
In the SDK you can do something like this:
WorkItem item = ...;
item.Attachments.Add(new Attachment("c:\\path\\on\\tfs\\server\\shot.png", "Screen shot"));
item.Save();
But this requires the file being attached to be placed on either a network accessible path, or on a disk in the TFS server itself.
In our case the file being attached is just an in-memory blob, and having to save attachments to a physical path seems unnecessary and definitely complicates the deployment steps required by our customers, as we need to put them on the file system, and then subsequently remove them once the work item has been created.
Is there any way to attach a file without having to place it on the file system - ideally I'm thinking of, say, just providing a byte array, file name and mime type?
Update
Appears the consensus is that this is not possible - and t开发者_开发技巧he work around is to write your own attachment class, that wraps up the functionality to create a temporary attachment file on the disk:
http://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336044
This is not possible.
There is a nice implementation of adding a screenshot to the work item using a temporary file: http://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336038
精彩评论