q*****z 发帖数: 191 | 1 Hi,
I am new to .net but have used c for years. I met a problem recently using .
net C++. What I want to do is to use openFileDialog() to open a file and
write some binary information to it. Here is what I have:
SaveFileDialog^ d = gcnew SaveFileDialog;
d->Filter = "exp files (*.exp)|*.exp";
if (d->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
FILE *fid;
fopen(fid,d->FileName,'wb+');
fwrite(buf,1,frameSize,fid);
fclose(fid);
}
It seems like d->Filename does't return the standard st | l*s 发帖数: 783 | 2 MSDN上的code不work?
private:
void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Stream^ myStream;
SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
saveFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*
";
saveFileDialog1->FilterIndex = 2;
saveFileDialog1->RestoreDirectory = true;
if ( saveFileDialog1->ShowDialog() == ::DialogResult::OK )
{
if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
【在 q*****z 的大作中提到】 : Hi, : I am new to .net but have used c for years. I met a problem recently using . : net C++. What I want to do is to use openFileDialog() to open a file and : write some binary information to it. Here is what I have: : SaveFileDialog^ d = gcnew SaveFileDialog; : d->Filter = "exp files (*.exp)|*.exp"; : if (d->ShowDialog() == System::Windows::Forms::DialogResult::OK) : { : FILE *fid; : fopen(fid,d->FileName,'wb+');
| q*****z 发帖数: 191 | 3 Thanks a lot! I did try but since I am new to the managed coding style I
have no clue what is happening.
The following line has error:
myStream->Write(buf,0,frameSize);
error C2664: 'System::IO::Stream::Write' : cannot convert parameter 1 from
'unsigned char *' to 'cli::array ^' | q*****z 发帖数: 191 | 4 Thanks a lot! I did try but since I am new to the managed coding style I
have no clue what is happening.
The following line has error:
myStream->Write(buf,0,frameSize);
error C2664: 'System::IO::Stream::Write' : cannot convert parameter 1 from
'unsigned char *' to 'cli::array ^' | t*******y 发帖数: 81 | 5 buf is native type unsigned char*, here you need managed type array.
from
【在 q*****z 的大作中提到】 : Thanks a lot! I did try but since I am new to the managed coding style I : have no clue what is happening. : The following line has error: : myStream->Write(buf,0,frameSize); : error C2664: 'System::IO::Stream::Write' : cannot convert parameter 1 from : 'unsigned char *' to 'cli::array ^'
|
|