0

I want to extract with SharpZipLib to extract.

I use this for extract on %appdata% but i want to extract in a subfolder of Roaming

string appdata = System.Environment.GetFolderPath(
                   System.Environment.SpecialFolder.ApplicationData)

My question is how I extract to %appdata%\subfolder?

Thanks

competent_tech
  • 44,465
  • 11
  • 90
  • 113
TheMrRafus
  • 35
  • 1
  • 1
  • 6

2 Answers2

1

Use Path.Combine to generate absolute path for your subfolder -

string subFolderPath = System.IO.Path.Combine(appdata,"subfolder");
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
0

I guess there's two ways of doing this really, one using string concatenation and the other using using Path.Combine

string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\subfolder";

Or

string folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "subfolder");

Personally I am not sure which is the "better" option, I guess when it comes down to it they do the same thing.

Jsm
  • 76
  • 3
  • Have you tried it? This won't even compile since `Environment.SpecialFolder.ApplicationData` is not string and `Path.Combine` expects string parameter. – Rohit Vats Jul 07 '13 at 19:09
  • Now I feel silly, I copy / pasted it from something I had open but in the process of removing certain things from it I broke it entirely. Thanks for pointing out. – Jsm Jul 07 '13 at 19:10