0

is there a way to rename a file that you have extracted using FastZip?

Or do I have to rename it manually using File?

svick
  • 236,525
  • 50
  • 385
  • 514
Vasa Serafin
  • 306
  • 5
  • 18

2 Answers2

1

I don't think so, I think you'll have to rename it with file (or fileinfo). If you are doing the renaming often and in a particular way you might want to wrap FastZip to include the renaming operations. You might want to wrap File in order to write unit tests without using the file system.

Sean
  • 696
  • 2
  • 9
  • 24
  • OK thanks I was just thinking of using `rename();`, but I have to figure out how I am going to find the extracted files name. – Vasa Serafin Jul 21 '12 at 11:10
  • If you know the folder you can use Directory.GetFiles - http://msdn.microsoft.com/en-us/library/07wt70x2.aspx, and if there is hierachy you can use Directory.GetDirectories to find the files. Both methods allow some sort of filtering. – Sean Jul 21 '12 at 11:15
  • Yep I just did that ha-ha, this should work should it not?`newFile.readSortTextAltech(Directory.GetFiles("Extracted")[0], progressBar1);` I am contemplating using a `.ToString();` but I think the method should come out as a string anyway. Now just to see if there is a way to order by date and then just grab the latest file. – Vasa Serafin Jul 21 '12 at 11:20
1

You will have to rename it after the unzip operation has completed. But - why not write an extension method to the FastZip ExtractZip() method?

Kane
  • 16,471
  • 11
  • 61
  • 86
  • How would you go about the renaming? Using `rename(oldFile, newFile);`? If so is there a way for the program to retrieve what the file name of the file that was extracted is? – Vasa Serafin Jul 21 '12 at 11:15