1
I’m making a Console Application in C# which, given an array of file names it returns the address of each and adds them to a Dotnetzip Zipfile.
Currently I code lies like this:
string[] nomes = {
"C:\\users\\fabio\\desktop\\pastateste\\teste1.txt",
"C:\\users\\fabio\\desktop\\pastateste\\teste5.txt",
"C:\\users\\fabio\\desktop\\pastateste\\teste6.txt",
"C:\\users\\fabio\\desktop\\pastateste\\teste10.txt"};
using(ZipFile zip = new ZipFile())
{
foreach (string item in nomes)
{
if (File.Exists(item))
zip.AddFile(item, "arquivos");
}
zip.Save("C:\\users\\fabio\\desktop\\compactteste.zip");
The "pastateste" folder contains . txt files from 1 to 10 and I just select {1,5,6,10}, but passing the full address of each file in the names array.
How can I rummage through the "pastateste" folder, pick up the address of the test files{1,5,6,10} and store them in another array?
System.IO.Path.GetFullPath
may be what you seek– Natan Fernandes
I believe that using the methods of the System.IO library you can, look at the File and Directory classes. To list files from a directory you can use Directory.Getfiles()
– M. Bertolazo
Fabio, I can not understand what you want to do effectively... You can [Dit] your question and try to be a little more specific?
– Jéf Bueno
@LINQ Edited! I tried to be clearer now.
– Fabio Hagiwara