2012-09-18 32 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); 
} 
相關問題