Click here to Skip to main content
15,905,971 members
Home / Discussions / C#
   

C#

 
AnswerRe: changing color of the pointed treeView node Pin
Christian Graus18-Jan-07 22:57
protectorChristian Graus18-Jan-07 22:57 
AnswerRe: changing color of the pointed treeView node Pin
Mircea Puiu19-Jan-07 1:03
Mircea Puiu19-Jan-07 1:03 
QuestionGeneric sum Pin
V. Thieme18-Jan-07 22:15
V. Thieme18-Jan-07 22:15 
AnswerRe: Generic sum Pin
Russell Jones18-Jan-07 22:38
Russell Jones18-Jan-07 22:38 
GeneralRe: Generic sum Pin
V. Thieme18-Jan-07 23:37
V. Thieme18-Jan-07 23:37 
AnswerRe: Generic sum Pin
Christian Graus18-Jan-07 22:57
protectorChristian Graus18-Jan-07 22:57 
GeneralRe: Generic sum Pin
V. Thieme18-Jan-07 23:36
V. Thieme18-Jan-07 23:36 
QuestionLoading an image as a byte array Pin
Russell Jones18-Jan-07 22:11
Russell Jones18-Jan-07 22:11 
I'm trying to load an image into a byte array. The following code seems to be OK for the moment but i'm worried that it's not right.

FileStream fs = new FileStream(FileName,FileMode.Open);<br />
byte [] ImageData = new byte[fs.Length];<br />
fs.Read(ImageData,0,(int)fs.Length);


Firstly, while i can't see anyone loading files bigger than int.MaxValue any time soon, it's always nice to future proof your code and someone might load a video that big, even today. For the application I'm using it for I'll probably block files over about 10 Meg anyway so I can ignore this issue.(I might stick in a LATER: comment and come back to it)

Second and of more immediate concern is that I read somewhere (but have now lost the link) that fs.Read will block until it has some data, not necessarily all the data in the stream.

Is my simple code OK or should I be checking whether the stream is fully loaded before i do things with the data? It seems to work allright at the moment but this is a reasonably fast machine with good disks and not much swap file use.

Russell
AnswerRe: Loading an image as a byte array Pin
Christian Graus18-Jan-07 22:56
protectorChristian Graus18-Jan-07 22:56 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:01
Russell Jones18-Jan-07 23:01 
AnswerRe: Loading an image as a byte array Pin
Guffa18-Jan-07 22:56
Guffa18-Jan-07 22:56 
AnswerRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:03
sitebuilderLuc Pattyn18-Jan-07 23:03 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:02
Russell Jones18-Jan-07 23:02 
GeneralRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:10
sitebuilderLuc Pattyn18-Jan-07 23:10 
GeneralRe: Loading an image as a byte array Pin
Russell Jones18-Jan-07 23:39
Russell Jones18-Jan-07 23:39 
GeneralRe: Loading an image as a byte array Pin
Luc Pattyn18-Jan-07 23:46
sitebuilderLuc Pattyn18-Jan-07 23:46 
Generalbug in doc Pin
Luc Pattyn18-Jan-07 23:58
sitebuilderLuc Pattyn18-Jan-07 23:58 
GeneralRe: bug in doc Pin
Russell Jones19-Jan-07 0:32
Russell Jones19-Jan-07 0:32 
QuestionData Transfer to new table Pin
Bulky Fellow18-Jan-07 22:06
Bulky Fellow18-Jan-07 22:06 
AnswerRe: Data Transfer to new table Pin
mihksoft18-Jan-07 22:49
mihksoft18-Jan-07 22:49 
AnswerRe: Data Transfer to new table Pin
Russell Jones18-Jan-07 22:54
Russell Jones18-Jan-07 22:54 
GeneralRe: Data Transfer to new table Pin
Bulky Fellow24-Jan-07 21:35
Bulky Fellow24-Jan-07 21:35 
QuestionBest way of stopping program after caught in catch{} Pin
livez18-Jan-07 21:49
livez18-Jan-07 21:49 
AnswerRe: Best way of stopping program after caught in catch{} Pin
Stefan Troschuetz18-Jan-07 21:57
Stefan Troschuetz18-Jan-07 21:57 
AnswerRe: Best way of stopping program after caught in catch{} Pin
quiteSmart18-Jan-07 21:58
quiteSmart18-Jan-07 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.