2010-05-26 146 views
1

我有方法:返回多个值与流

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

服务与流媒体我的WCF服务,我想有方法对这样的服务:

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 
} 

现在我唯一的方法(这是下面)哪些工作正常,但我必须将其转换为我顶层descibe功能。

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

我必须从服务路径搞懂什么是文件

回答

1

您可以使用类似

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

感谢答案。不幸的是,这不适用于流,但我在其他地方添加这段代码蚂蚁它是很好:) – user278618 2010-05-26 08:06:21

+0

我想你的意思是,WCF不能返回Dictionary 。 你需要的是流传输 - 阅读此http://msdn.microsoft.com/en-us/library/ms731913.aspx – 2010-05-26 08:14:58