views:

26

answers:

1

Hi,

I have method:

var listOfFiles=service .GetFiles(pathsOfFiles.ToArray();

service is my wcf service with streaming ,and I want to have method on this service like :

public  List<Stream, file> GetFiles(string[] paths)
{
List<Stream, file> files =new List<Stream, file>
foreach(string path in pathsOfFiles)
{
files.add(path, new FileStream(filename, FileMode.Open))
}
return files
}

Now I have only method (which is below) which works fine, but I must convert it to function which I descibe on top.

public Stream GetData(string filename)
        {
            FileStream fs = new FileStream(filename, FileMode.Open);
            return fs;
        }

I must get from service paths to know what is the name of file

+1  A: 

You can use something like

public Dictionary<string, Stream> GetData(string[] paths)
{
    Dictionary<string, Stream> data = new Dictionary<string, Stream>();
    foreach (string path in paths)
    {
        data[path] = new FileStream(path, FileMode.Open);       
    }

    return data;
}
Itay
thanks for answer. Unfortunately this doesn't works with stream, but i add this piece of code in other place ant it is nice :)
I guess that what you meant is that WCF cannot return Dictionary<string, Stream>.what you need is stream tranfer - read this http://msdn.microsoft.com/en-us/library/ms731913.aspx
Itay