Joshua Frank
Joshua Frank

Reputation: 13828

Why won't it let me delete files from TFS?

I've got some files that are automatically generated and placed in a directory that's versioned using TFS. I run this and add many files like abc.sql to the server.

Then I rerun my script and something's changed such that abc is obsolete. My script deletes abc.sql from the local Windows folder.

When I run a Compare in TFS, it picks up the missing file, but when I try to choose Delete to remove the file from the server as well, I get this error:

The item $/.../abc.sql could not be found in your workspace, 
or you do not have permission to access it.

I know it's not in my workspace, and that's intentional. So how can I delete a file locally, and tell TFS to delete from the server as well?

Upvotes: 0

Views: 1132

Answers (2)

Markus
Markus

Reputation: 22421

Instead of just deleting the file in the file system, you should also mark it as deleted in the workspace and check the delete in afterwards.

If you already add files to source control, you can also mark them as deleted, e.g. by running tf delete. This command also removes the file from the disk. From a .NET application, you can start it by using System.Diagnostics.Process.

Upvotes: 3

Jon Barker
Jon Barker

Reputation: 1828

You don't need to delete the file locally, just have your script delete the file from TFS. Upon commit to source control, the file is deleted locally.

http://msdn.microsoft.com/en-us/library/k45zb450(v=vs.100).aspx

tf delete [/lock:(none|checkin|checkout)] [/recursive] [/login:username,[password]] itemspec

Upvotes: 1

Related Questions