Redian新闻
>
How to use openFileDialog() to save a binary file in .net C++
avatar
How to use openFileDialog() to save a binary file in .net C++# DotNet - 窗口里的风景
q*z
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
avatar
l*s
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+');

avatar
q*z
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 ^'
avatar
q*z
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 ^'
avatar
t*y
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 ^'

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。