How can txt files be edited in zip archives



  • There's a zip archive. It's 1,000 txt files. I have to edit them all.

    Example: name-lord

    • first replacement ame-lordRemove(0.1)
    • second replacement ame-wordReplace("-l,"-w)
    • and last same-word (S the letter at the beginning of the file)

    How do you do in c#?

    What archive is it and the algorithm is going to be... ♪ ♪



  • Using the library http://dotnetzip.codeplex.com/ You can do this:

    Example http://grapevine.dyndns-ip.com/download/authentec/download/dotnetzip/examples.htm

     using (ZipFile zip2 = ZipFile.Read(ExistingZipFile))
     {
        foreach (ZipEntry e in zip2)
        {
          if (e.FileName.EndsWith(".txt"))
          {
             var newname = e.FileName + "rename";
             e.FileName = newname;
          }
        }
        zip2.Save();
     }
    

    Change all files with extension. .txtadding to the existing name of every souffix file. rename

    For your case, replace the corresponding line with the following code:

    var newname = e.FileName.Substring(1, s.Length - 1); // первая замена
    newname = newname.Replace("-l", "-w" ); // вторая замена
    newname = "s" + newname; // третья замена
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2