If you work with TFS 2010 or TFS 2012 work items, you know you can attach files. Sometimes you need to attach large files. If these are too big TFS will tell you about it.
As suggested, you can put the file in Source Control and then link to it. However, if you really need to attach the file, you can increase the size limit for the attachments.
Below you will find 2 methods you can use to accomplish this.
Method #1 – Web Service
Method #2 – C#
Programmatically, update the value directly in the TFS Registry.
<span style="color: #008000">/// <summary></span>
<span style="color: #008000">/// Sets the maximum attachment size for the given server.</span>
<span style="color: #008000">/// </summary></span>
<span style="color: #008000">/// <param name="tfsUrl">The TFS URL.</param></span>
<span style="color: #008000">/// <param name="newAttachmentSize">The new maximum attachment size.</param></span>
<span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> SetMaximumAttachmentSize(<span style="color: #0000ff">string</span> tfsUrl, <span style="color: #0000ff">long</span> newAttachmentSize)
{
var configServer = TfsConfigurationServerFactory.GetConfigurationServer(<span style="color: #0000ff">new</span> Uri(tfsUrl));
var rw = configServer.GetService<ITeamFoundationRegistry>();
var rc = rw.ReadEntries(<span style="color: #006080">@"/Service/WorkItemTracking/Settings/MaxAttachmentSize"</span>);
<span style="color: #0000ff">if</span> (rc.Count > 0)
{
var re = rc.First();
re.Value = newAttachmentSize.ToString(CultureInfo.InvariantCulture);
rw.WriteEntries(<span style="color: #0000ff">new</span> List<RegistryEntry> { re });
}
}