none
TFS File Deletion using API RRS feed

  • Question

  • Hello can anyone tell me how to delete files using the API for TFS?  Below is what I have but I can not get it to work any help would really be appreciated.

    string[] InLocalDirectory = Directory.GetFiles(LogicAppConfig.Query(AppConfigLogic.TypeOfConfig.Path), "*", SearchOption.AllDirectories);

                    // Source Control
                    List<string> InSourceControl = new List<string>();
                    ItemSet SetOfItem = _ServerVersionControl.GetItems(_ServerPath, VersionSpec.Latest, RecursionType.Full);
                    foreach (Item GotItem in SetOfItem.Items)
                    {
                        ItemType TypeOfItem = GotItem.ItemType;
                        if (TypeOfItem == ItemType.File)
                        {
                            string LocalPath = _WorkspaceLocal.GetLocalItemForServerItem(GotItem.ServerItem);
                            InSourceControl.Add(LocalPath);
                        }
                    }

                    List<int> ToDeleteById = new List<int>();
                    foreach (string SourceFile in InSourceControl)
                    {
                        if (!IsIgnored(SourceFile) && !InLocalDirectory.Contains(SourceFile))
                        {
                            // Delete Source Control File
                            Item DeleteItem = _ServerVersionControl.GetItem(SourceFile);
                            ToDeleteById.Add(DeleteItem.ItemId);
                            // Update Local XML Directory
                            DataXml.Delete(SourceFile);
                        }
                    }
                    
                    WorkItemStore wis = _CollectionTeamProject.GetService<WorkItemStore>();
                    wis.DestroyWorkItems(ToDeleteById);

    Thursday, March 29, 2018 7:34 PM

All replies

  • The code above is used for Team Foundation Server.  Our team wrote so we can allow our members to get source code without having to use VS2017 as it is too confusing for some of them.

    Thank you for responding but this has nothing to do with FTP.

    Friday, March 30, 2018 2:26 PM
  • Hi Curator785,

    Thank you for posting here.

    For your question, I misunderstand what you want.

    If you want to delete TFS files, you could post a new thread in StackOverFlow.

    https://stackoverflow.com/questions/tagged/tfs

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 2, 2018 7:47 AM
  • Thank you have done so

    stackoverflow.com/questions/49614112/issue-with-api-deleting-for-team-foundation-server-tfs
    Monday, April 2, 2018 3:36 PM
  • Hi Curator785,

    Thank you for feedback.

    I hope the supporter there could give you a solution.

    If you have more question about CLR, please feel free to contact us.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 3, 2018 5:49 AM