Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. New article: Fast Search and Replace in Large Number of Files: A Practical Guide

New article: Fast Search and Replace in Large Number of Files: A Practical Guide

Scheduled Pinned Locked Moved The Lounge
csharpvisual-studiowinformstoolsperformance
23 Posts 14 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Richard DeemingR Richard Deeming

    Brian C Hart wrote:

    I just wanted to share a link to an article I just posted, today

    Don't do this. There is already a feed of recently posted articles[^], and multiple newsletters which list the recently posted articles. Anyone who is interested in the topic will see your article there and read it. Recent articles are also posted on the CodeProject Twitter feed, for those who still use that site. Posting in The Lounge to promote your new article stinks of spam / rep-point hunting. Imagine how useless the forum would become if every author did this! You think it's annoying having a daily Wordle thread? Having page after page of "Check out my new article", "No, check out MY new article", "My new article is better than your new article"" etc. threads would be a thousand times worse. And it's not going to achieve much. By this time next week, your article promotion post will be buried on page 42, where nobody is ever likely to see it. So seriously, don't do this. :suss:


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #5

    And yet he gets 4 up-votes. :wtf:

    1 Reply Last reply
    0
    • Richard DeemingR Richard Deeming

      Brian C Hart wrote:

      I just wanted to share a link to an article I just posted, today

      Don't do this. There is already a feed of recently posted articles[^], and multiple newsletters which list the recently posted articles. Anyone who is interested in the topic will see your article there and read it. Recent articles are also posted on the CodeProject Twitter feed, for those who still use that site. Posting in The Lounge to promote your new article stinks of spam / rep-point hunting. Imagine how useless the forum would become if every author did this! You think it's annoying having a daily Wordle thread? Having page after page of "Check out my new article", "No, check out MY new article", "My new article is better than your new article"" etc. threads would be a thousand times worse. And it's not going to achieve much. By this time next week, your article promotion post will be buried on page 42, where nobody is ever likely to see it. So seriously, don't do this. :suss:


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      A Offline
      A Offline
      Amarnath S
      wrote on last edited by
      #6

      At a first glance, it looked like a self appraisal by an employee of a large company.

      1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Brian C Hart wrote:

        I just wanted to share a link to an article I just posted, today

        Don't do this. There is already a feed of recently posted articles[^], and multiple newsletters which list the recently posted articles. Anyone who is interested in the topic will see your article there and read it. Recent articles are also posted on the CodeProject Twitter feed, for those who still use that site. Posting in The Lounge to promote your new article stinks of spam / rep-point hunting. Imagine how useless the forum would become if every author did this! You think it's annoying having a daily Wordle thread? Having page after page of "Check out my new article", "No, check out MY new article", "My new article is better than your new article"" etc. threads would be a thousand times worse. And it's not going to achieve much. By this time next week, your article promotion post will be buried on page 42, where nobody is ever likely to see it. So seriously, don't do this. :suss:


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #7

        I'm holding off with the spam vote, but the article points to a youtube channel and states that the author may be offered incentives for pointing people to that channel.

        Advanced TypeScript Programming Projects

        Richard DeemingR Brian C HartB 2 Replies Last reply
        0
        • P Pete OHanlon

          I'm holding off with the spam vote, but the article points to a youtube channel and states that the author may be offered incentives for pointing people to that channel.

          Advanced TypeScript Programming Projects

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #8

          Good spot! Probably worth flagging that up to @sean-ewington for review.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • P Pete OHanlon

            I'm holding off with the spam vote, but the article points to a youtube channel and states that the author may be offered incentives for pointing people to that channel.

            Advanced TypeScript Programming Projects

            Brian C HartB Offline
            Brian C HartB Offline
            Brian C Hart
            wrote on last edited by
            #9

            Full disclousre: I am a fan of that youtube channel, but I was just mentioning it as opposed to sponsoring it per see. I was just wanting to be transparent an honest. However, I did the R&D of the article myself, and it's my own original work! And I do think that the person on the YouTube channel has good things to say in regard to optimizing the performance of C# software. It's kind of like CNN reporting on something their parent company does, and then saying, "Oh and by the way, CNN is owned by Warner Bros/Discovery." I'm all about being honest and transparent, but I am not above asking the person who is behind said YouTube channel if they want to enter into a mutually beneficial arrangement.

            1 Reply Last reply
            0
            • Brian C HartB Brian C Hart

              See here: Fast Search and Replace in Large Number of Files: A Practical Guide[^] Hello all, My name is Dr. Brian Hart, and I am a PhD astrophysicist and one of the original users of The Code Project from back in the year 2000. I've written many articles in C++ and C# programming. I just wanted to share a link to an article I just posted, today, on The Code Project. I hope you will stop by and take a look. It's about using memory-mapped files in C# to do a search and replace a large number of files fast. I implemented the algorithm both as a (really bare-bones) console application and a more graphical/user-friendly Windows Forms tool. It came out of work that I was doing on this .sln file that contains almost 1,000 projects in Visual Studio, and I was pushing my existing Find In Files / Replace In Files tools to the limit. I needed to write my fast algorithm as part of a file- and project-renaming tool I was writing, partly to manage the refactoring of so much code. The code included with the article compiles (after doing a nuget restore in the Solution directory). It should be informative and a great example of processing a huge number of files really fast. The impetus of the article was trying to imitate the speed with which Notepad++ processes files with its Find in Files and Replace in Files operations. I also include code to create a progress dialog in WinForms and report the operation's progress to the user while keeping the GUI responsive. I hope it helps someone with their programming work! Regards, Brian Hart

              D Offline
              D Offline
              dandy72
              wrote on last edited by
              #10

              Brian C Hart wrote:

              My name is Dr. Brian Hart, and I am a PhD astrophysicist

              Cool accolades bro. But how does this come into play in relation with the article you're trying to promote?

              Brian C HartB 1 Reply Last reply
              0
              • D dandy72

                Brian C Hart wrote:

                My name is Dr. Brian Hart, and I am a PhD astrophysicist

                Cool accolades bro. But how does this come into play in relation with the article you're trying to promote?

                Brian C HartB Offline
                Brian C HartB Offline
                Brian C Hart
                wrote on last edited by
                #11

                Nothing. It's just a crass attempt to puff myself up and make myself seem smarter than I really am (or so some of my friends think). ;-) It's just me introducing myself. Probably a lot like this guy[^]. Ha ha ha... Regards, Brian Hart

                J D 2 Replies Last reply
                0
                • Brian C HartB Brian C Hart

                  See here: Fast Search and Replace in Large Number of Files: A Practical Guide[^] Hello all, My name is Dr. Brian Hart, and I am a PhD astrophysicist and one of the original users of The Code Project from back in the year 2000. I've written many articles in C++ and C# programming. I just wanted to share a link to an article I just posted, today, on The Code Project. I hope you will stop by and take a look. It's about using memory-mapped files in C# to do a search and replace a large number of files fast. I implemented the algorithm both as a (really bare-bones) console application and a more graphical/user-friendly Windows Forms tool. It came out of work that I was doing on this .sln file that contains almost 1,000 projects in Visual Studio, and I was pushing my existing Find In Files / Replace In Files tools to the limit. I needed to write my fast algorithm as part of a file- and project-renaming tool I was writing, partly to manage the refactoring of so much code. The code included with the article compiles (after doing a nuget restore in the Solution directory). It should be informative and a great example of processing a huge number of files really fast. The impetus of the article was trying to imitate the speed with which Notepad++ processes files with its Find in Files and Replace in Files operations. I also include code to create a progress dialog in WinForms and report the operation's progress to the user while keeping the GUI responsive. I hope it helps someone with their programming work! Regards, Brian Hart

                  J Offline
                  J Offline
                  jochance
                  wrote on last edited by
                  #12

                  Got to the bit about Notepad++ and cackled because I'd been thinking up to there, "man, Notepad++ is really good at that..."

                  Brian C HartB 1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    Brian C Hart wrote:

                    I just wanted to share a link to an article I just posted, today

                    Don't do this. There is already a feed of recently posted articles[^], and multiple newsletters which list the recently posted articles. Anyone who is interested in the topic will see your article there and read it. Recent articles are also posted on the CodeProject Twitter feed, for those who still use that site. Posting in The Lounge to promote your new article stinks of spam / rep-point hunting. Imagine how useless the forum would become if every author did this! You think it's annoying having a daily Wordle thread? Having page after page of "Check out my new article", "No, check out MY new article", "My new article is better than your new article"" etc. threads would be a thousand times worse. And it's not going to achieve much. By this time next week, your article promotion post will be buried on page 42, where nobody is ever likely to see it. So seriously, don't do this. :suss:


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    J Offline
                    J Offline
                    jochance
                    wrote on last edited by
                    #13

                    I get where you're coming from and all and ain't nothin' round here even if I've been around a long bit too. But... The guy's been here ~25 years, so it's playing the long game just to be a spammy spammer. Pretty impressive bio. He probably doesn't drink, but if we had looser legal definitions around kidnapping and controlled substances then chucking him into a van and pumping him full of loose lips might get real interesting real fast.

                    1 Reply Last reply
                    0
                    • J jochance

                      Got to the bit about Notepad++ and cackled because I'd been thinking up to there, "man, Notepad++ is really good at that..."

                      Brian C HartB Offline
                      Brian C HartB Offline
                      Brian C Hart
                      wrote on last edited by
                      #14

                      I've been working on a tool that combines the following three operations: 1) Rename folders in a root folder's tree (according to certain rules) 2) Rename files in a root folder's tree (according to certain rules) 3) Replace text in files throughout the root folder's tree (according to certain rules). The tool allows me to basically have a "Find and Replace of Solution Explorer". Say I added a whole bunch of class libraries called Foo.MyLibrary.Bar.IsAwsome, Foo.MyLibrary.Bar.IsAwsome.Constants, Foo.MyLibrary.Bar.IsAwsome.Extensions, Foo.MyLibrary.Bar.IsAwsome.Factories, Foo.MyLibrary.Bar.IsAwsome.Interfaces, and now I say, I want to change the names of the projects, the names of the folders in which they live, and update the .sln file and all namespaces and corresponding using statements, etc. so the code still builds, replacing MyLibrary with Aardvark everywhere, this tool will do that for me. However, I had this one solution that had, like, 980+ projects in it, and for operation #3 you really have to somehow go through each and every file in a folder tree and do a find and replace, and instead of having to shell over to Notepad++ to do that, I wanted to integrate a file search and replace operation of similar performance into my tool so it can just take care of it as swiftly, or almost as swiftly, as Notepad++.

                      J 1 Reply Last reply
                      0
                      • Richard DeemingR Richard Deeming

                        Brian C Hart wrote:

                        I just wanted to share a link to an article I just posted, today

                        Don't do this. There is already a feed of recently posted articles[^], and multiple newsletters which list the recently posted articles. Anyone who is interested in the topic will see your article there and read it. Recent articles are also posted on the CodeProject Twitter feed, for those who still use that site. Posting in The Lounge to promote your new article stinks of spam / rep-point hunting. Imagine how useless the forum would become if every author did this! You think it's annoying having a daily Wordle thread? Having page after page of "Check out my new article", "No, check out MY new article", "My new article is better than your new article"" etc. threads would be a thousand times worse. And it's not going to achieve much. By this time next week, your article promotion post will be buried on page 42, where nobody is ever likely to see it. So seriously, don't do this. :suss:


                        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                        0 Offline
                        0 Offline
                        0x01AA
                        wrote on last edited by
                        #15

                        I really appreciate your contributions, especially in Q/A. But I think declaring the article in question as spam is massively below your level. Only my view.

                        Richard DeemingR 2 Replies Last reply
                        0
                        • Brian C HartB Brian C Hart

                          I've been working on a tool that combines the following three operations: 1) Rename folders in a root folder's tree (according to certain rules) 2) Rename files in a root folder's tree (according to certain rules) 3) Replace text in files throughout the root folder's tree (according to certain rules). The tool allows me to basically have a "Find and Replace of Solution Explorer". Say I added a whole bunch of class libraries called Foo.MyLibrary.Bar.IsAwsome, Foo.MyLibrary.Bar.IsAwsome.Constants, Foo.MyLibrary.Bar.IsAwsome.Extensions, Foo.MyLibrary.Bar.IsAwsome.Factories, Foo.MyLibrary.Bar.IsAwsome.Interfaces, and now I say, I want to change the names of the projects, the names of the folders in which they live, and update the .sln file and all namespaces and corresponding using statements, etc. so the code still builds, replacing MyLibrary with Aardvark everywhere, this tool will do that for me. However, I had this one solution that had, like, 980+ projects in it, and for operation #3 you really have to somehow go through each and every file in a folder tree and do a find and replace, and instead of having to shell over to Notepad++ to do that, I wanted to integrate a file search and replace operation of similar performance into my tool so it can just take care of it as swiftly, or almost as swiftly, as Notepad++.

                          J Offline
                          J Offline
                          jochance
                          wrote on last edited by
                          #16

                          Yeah... Resharper/VS has an "adjust namespaces" but that just didn't quite get it when it's hundreds of files getting changed. Notepad++ did way better there for me but you do sort of want it in VS. If you make it good enough maybe MSFT will come relieve you of the code and leave you a check.

                          1 Reply Last reply
                          0
                          • Brian C HartB Brian C Hart

                            See here: Fast Search and Replace in Large Number of Files: A Practical Guide[^] Hello all, My name is Dr. Brian Hart, and I am a PhD astrophysicist and one of the original users of The Code Project from back in the year 2000. I've written many articles in C++ and C# programming. I just wanted to share a link to an article I just posted, today, on The Code Project. I hope you will stop by and take a look. It's about using memory-mapped files in C# to do a search and replace a large number of files fast. I implemented the algorithm both as a (really bare-bones) console application and a more graphical/user-friendly Windows Forms tool. It came out of work that I was doing on this .sln file that contains almost 1,000 projects in Visual Studio, and I was pushing my existing Find In Files / Replace In Files tools to the limit. I needed to write my fast algorithm as part of a file- and project-renaming tool I was writing, partly to manage the refactoring of so much code. The code included with the article compiles (after doing a nuget restore in the Solution directory). It should be informative and a great example of processing a huge number of files really fast. The impetus of the article was trying to imitate the speed with which Notepad++ processes files with its Find in Files and Replace in Files operations. I also include code to create a progress dialog in WinForms and report the operation's progress to the user while keeping the GUI responsive. I hope it helps someone with their programming work! Regards, Brian Hart

                            J Offline
                            J Offline
                            jschell
                            wrote on last edited by
                            #17

                            I know I have used at least one commercial tool which has a low cost which seemed to have no problem with doing searches and replaces. And provided many options including regexes. If someone needs to to this hundreds of times a day on a code base then something is wrong with the code base. If they need to do it once a year then they should buy one of the tools and use it. I wouldn't be surprised if there are some free ones also.

                            1 Reply Last reply
                            0
                            • Brian C HartB Brian C Hart

                              Nothing. It's just a crass attempt to puff myself up and make myself seem smarter than I really am (or so some of my friends think). ;-) It's just me introducing myself. Probably a lot like this guy[^]. Ha ha ha... Regards, Brian Hart

                              J Offline
                              J Offline
                              Jorgen Andersson
                              wrote on last edited by
                              #18

                              A good place for that is your message signature. Edit here -> [Your Settings](https://www.codeproject.com/script/Membership/Modify.aspx) (On the "Forums & QA" tab)

                              Wrong is evil and must be defeated. - Jeff Ello

                              1 Reply Last reply
                              0
                              • 0 0x01AA

                                I really appreciate your contributions, especially in Q/A. But I think declaring the article in question as spam is massively below your level. Only my view.

                                Richard DeemingR Offline
                                Richard DeemingR Offline
                                Richard Deeming
                                wrote on last edited by
                                #19

                                Any article which promotes a YouTube channel for with the author receives a kick-back counts as spam, regardless of how long the user has been around or how many articles they've published. That's why I reported the article, but not the user. He can then discuss the matter with Sean. And I notice you replied to my message telling him not to promote his article in The Lounge, rather than Pete's reply pointing out the suspicious sponsored link in the article. :confused:


                                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                1 Reply Last reply
                                0
                                • 0 0x01AA

                                  I really appreciate your contributions, especially in Q/A. But I think declaring the article in question as spam is massively below your level. Only my view.

                                  Richard DeemingR Offline
                                  Richard DeemingR Offline
                                  Richard Deeming
                                  wrote on last edited by
                                  #20

                                  Also note that Sean has now removed the link: Re: Potential spam in article - Article Writing Discussion Boards[^]


                                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                  "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                                  1 Reply Last reply
                                  0
                                  • Brian C HartB Brian C Hart

                                    Nothing. It's just a crass attempt to puff myself up and make myself seem smarter than I really am (or so some of my friends think). ;-) It's just me introducing myself. Probably a lot like this guy[^]. Ha ha ha... Regards, Brian Hart

                                    D Offline
                                    D Offline
                                    dandy72
                                    wrote on last edited by
                                    #21

                                    Brian C Hart wrote:

                                    Nothing. It's just a crass attempt to puff myself up and make myself seem smarter than I really am

                                    I'm glad you're willing to put it that way. Some people take their titles way too seriously, and that irritates me to no end.

                                    1 Reply Last reply
                                    0
                                    • Brian C HartB Brian C Hart

                                      See here: Fast Search and Replace in Large Number of Files: A Practical Guide[^] Hello all, My name is Dr. Brian Hart, and I am a PhD astrophysicist and one of the original users of The Code Project from back in the year 2000. I've written many articles in C++ and C# programming. I just wanted to share a link to an article I just posted, today, on The Code Project. I hope you will stop by and take a look. It's about using memory-mapped files in C# to do a search and replace a large number of files fast. I implemented the algorithm both as a (really bare-bones) console application and a more graphical/user-friendly Windows Forms tool. It came out of work that I was doing on this .sln file that contains almost 1,000 projects in Visual Studio, and I was pushing my existing Find In Files / Replace In Files tools to the limit. I needed to write my fast algorithm as part of a file- and project-renaming tool I was writing, partly to manage the refactoring of so much code. The code included with the article compiles (after doing a nuget restore in the Solution directory). It should be informative and a great example of processing a huge number of files really fast. The impetus of the article was trying to imitate the speed with which Notepad++ processes files with its Find in Files and Replace in Files operations. I also include code to create a progress dialog in WinForms and report the operation's progress to the user while keeping the GUI responsive. I hope it helps someone with their programming work! Regards, Brian Hart

                                      R Offline
                                      R Offline
                                      Roger Wright
                                      wrote on last edited by
                                      #22

                                      Welcome back, Brian! It's been a long time. :-D Great article, too!

                                      Will Rogers never met me.

                                      1 Reply Last reply
                                      0
                                      • Brian C HartB Brian C Hart

                                        See here: Fast Search and Replace in Large Number of Files: A Practical Guide[^] Hello all, My name is Dr. Brian Hart, and I am a PhD astrophysicist and one of the original users of The Code Project from back in the year 2000. I've written many articles in C++ and C# programming. I just wanted to share a link to an article I just posted, today, on The Code Project. I hope you will stop by and take a look. It's about using memory-mapped files in C# to do a search and replace a large number of files fast. I implemented the algorithm both as a (really bare-bones) console application and a more graphical/user-friendly Windows Forms tool. It came out of work that I was doing on this .sln file that contains almost 1,000 projects in Visual Studio, and I was pushing my existing Find In Files / Replace In Files tools to the limit. I needed to write my fast algorithm as part of a file- and project-renaming tool I was writing, partly to manage the refactoring of so much code. The code included with the article compiles (after doing a nuget restore in the Solution directory). It should be informative and a great example of processing a huge number of files really fast. The impetus of the article was trying to imitate the speed with which Notepad++ processes files with its Find in Files and Replace in Files operations. I also include code to create a progress dialog in WinForms and report the operation's progress to the user while keeping the GUI responsive. I hope it helps someone with their programming work! Regards, Brian Hart

                                        E Offline
                                        E Offline
                                        englebart
                                        wrote on last edited by
                                        #23

                                        I like ye olde sed for this. It lets you batch as many search and replace operations as desired in a single pass. Read every character once and only once!

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups