Hey everyone I am new here and I found this site on google it looks pretty helpful and clean so I guess I am here to stay. However, I hope someone can solve my problem.

I am trying to create an ArrayList with both a URI and FileInfo (file destination) which I want to be connected to each other. I am using this for a download script and I have the ArrayList working perfect with just the URI to get the file sizes and add them up (for progress reasons).

The problem is when it gets to my Downloader.Download() method. I need the ArrayList to contain URI's but also a FileInfo object for each one so that the script may associate the URI to a download path.

Can anyone give me an example foreach() statement or point me in the right direction for sorting through the URIs and associating a FileInfo to each one WITHOUT hard coding the script?

Thanks in advance.

Thanks anyways guys, I already figured out an easy way to do it while I was playing a game. Haha.

Anyways just in case anyone has a similar problem, what I did was created a new class called Files and it went something like this:

//
        // Private variables.
        Uri _fileURI;
        FileInfo _fileDest;

        public Files(Uri fServer, FileInfo fDest)
        {
            _fileURI = fServer;
            _fileDest = fDest;
        }

        public Uri fileURI
        {
            get
            {
                return _fileURI;
            }
            set
            {
                _fileURI = value;
            }
        }

        public FileInfo fileDest
        {
            get
            {
                return _fileDest;
            }
            set
            {
                _fileDest = value;
            }
        }

I then changed my ArrayList to:

downloadQueue.Add(new Files(new Uri(sDServer + "filename.zip"), new FileInfo(sTempDir + "filename.zip")));

sDServer and sTempDir are just strings containing the URI up until the file name and the temporary download directory.

I then changed my foreach statement to:

foreach (Files file in downloadQueue)
                {
                    webRequest = WebRequest.Create(file.fileURI);
                    webResponse = webRequest.GetResponse();

                    _bytesOverall += webResponse.ContentLength;

                    if (webResponse != null)
                    {
                        webResponse.Close();
                    }
                }

And I will use file.fileDest for the save location in the download class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.