开发者

Return multiple values with stream

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


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜