Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:11:15+00:00 2026-06-08T07:11:15+00:00

I know there are already several questions about renaming files by using a version

  • 0

I know there are already several questions about renaming files by using a version control system. But I did not found a satisfactory answer to the special version control system Perforce.
My question:
Is there a plug-in/solution which keeps the version history of my C# code files when I renaming it within Visual Studio?

Edit: Currently I am using VS2P4 plug-in.

Edit2:
I have found a little shorter way to rename a file:

  1. Open containing folder in Explorer (in Solution Explorer right-click Open in Windows Explorer).
  2. Select file and right-click Perforce->Show in P4V.
  3. Do the normal rename/move action with selected file.

That scenario is shorter than navigating in Perforce Depot in P4V until I find the right file. But of course I am looking for a shorter way.

Edit3: Is there a way to directly do “Show in P4V” with file selection within VS?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:11:17+00:00Added an answer on June 8, 2026 at 7:11 am

    Macro

    I have a good solution now. Just handle macro event SolutionItemsEvents_ItemRenamed.
    This is done by open Macros IDE by clicking Tools->Macros->Macros IDE. Then add following event handler to your macro project:

        Private Sub SolutionItemsEvents_ItemRenamed(ByVal ProjectItem As EnvDTE.ProjectItem,
                                                    ByVal OldName As String)
                    Handles SolutionItemsEvents.ItemRenamed
    
            Dim process As System.Diagnostics.Process
    
            process.Start("p4", "move -k " & ProjectItem.Properties.Parent.Document.Path &
                          "\\" & OldName & " " & ProjectItem.Document.Path)
        End Sub
    

    See screenshot:
    enter image description here

    As you can see it just calls a “p4 move -k”. “-k” option is needed because after a rename the old file is already deleted, so Perforce would throw an error without “-k”. “-k” causes Perforce to rename the file on server only.

    If you get Perforce connection errors you need to add a P4CONFIG file where connection is defined. This is done by:

    • Add file p4config.txt to the directory of your project (or any of its parent directories) with content:

      P4CLIENT=your workspace
      P4USER=user
      P4PORT=p4server:1234

    • Set environment variable P4CONFIG=p4config.txt

    Now you can change your files by any way (Solution Explorer Item->Rename, Solution Explorer Item->F2, ReSharper’s Rename file to match type name, ReSharper’s class Rename (Ctrl+R,R),…).

    But keep in mind: I have problems if I try to edit and rename same file in one chek-in and if I rename a file while another person has checked-out same file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are already several similar questions here, but I need some recommendations
I know that there are already several questions on StackOverflow about std::string versus std::wstring
I know there are already some posts about this topic, but I cannot find
I know there are already objects supporting Office 2007 files, but is there any
I know there are already many questions like mine but I found no answer
I know there are several questions similar, but I can't find one that answers
Hey I know there are already a few posts about this - yet I
First of all: I do know that there are already many questions and answers
I know there are a few questions on stack already regarding this, and I
First of, I know there are similar questions already on stackoverflow ( this ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.