views:

180

answers:

4

Hello,

I have bmp images in image folder on my computer.I named it from 1.bmp to 100.bmp .

I want to read one by one these hundered images.And I wrote this code:

int i;
System::String^s;

for(i=1;i<=100;i++)
{
s=("C:\\images\\%d.bmp",i);
System::Drawing::Bitmap^ image;
image= gcnew System::Drawing::Bitmap(s,true );
}

And VS 2008 gave error in s=("C:\\images\\%d.bmp",i);

error C2440: '=' : cannot convert from 'int' to 'System::String ^'

Could you help me please?

A: 
s=("C:\\images\\%d.bmp",i);

This statement is wrong. I am not expert in C# but I think you can do following

s= "C:\\images\\" + i + ".bmp";
Alien01
+2  A: 

I think you want:

s=String::Format("C:\\images\\{0}.bmp",i);
Eric
I do not think so, String.Format can not recognize %d, as %d used in standard c/c++ functions (i.e. printf,sprintf..etc)
Ahmed Said
Yes, I think you're correct. I fixed it.
Eric
+2  A: 

I do not know much more about C++/CLI but in C# you can use

s = String.Format("C:\\images\\{0}.bmp",i);

I think in c++/cli may be

s = String::Format("C:\\images\\{0}.bmp",i);
Ahmed Said
A: 

Thank for your help.

yalcin