2012-09-18 31 views
0

我在做什么是这样的:无法转换的String []为byte []

ArrayList files = new ArrayList(); 
byte[] tempFile; 
string image; 

foreach (string file in files) 
{ 
    image = "/Images/Gallery/" + album.Substring(94) + "/" + file; 

    tempFile = Directory.GetFiles(image); 
} 

我不能转换的String [] Directory.GetFiles(图像)为byte []临时文件。 这怎么办?

+0

嘛,你要的文件列表转换 - 而不是内容 - 到字节数组。这真的*你想做什么? –

+0

'GetFiles'返回一串字符串!你不能将它转换为字节数组。也许是一个字节数组的数组? – Nasreddine

+1

使用**'Path.Combine' **而不是手动建立路径。目录separator char是平台相关的。 – Adam

回答

7

请试试这个:

...

{ 
    image = Path.Combine("Images", "Gallery", album.Substring(94), file); 
    tempFile = File.ReadAllBytes(image); 
} 
相关问题