|
-
March 30th, 1999, 04:21 AM
#1
Help! I can't create a file!
I try to create a file with this code :
DWORD dwWritten;
HANDLE myNewFile;
try
{
myNewFile = CreateFile(newFileName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
WriteFile(myNewFile,
&pDouble,
myFile.GetLength(),
&dwWritten,
NULL);
CloseHandle(myNewFile);
}
catch (CDaoException* e)
{
AfxMessageBox(e->m_pErrorInfo->m_strDescription);
e->Delete();
}
But no file is created!!!
The compiler says there is no error and no warning.
Could anyone help me find what's wrong in the code?
Thanks a lot.
-
March 30th, 1999, 05:12 AM
#2
Re: Help! I can't create a file!
If you just want simple read/write : it's easier to use streams.
-
March 13th, 2002, 03:16 PM
#3
Re: Help! I can't create a file!
I can't help with your code, but here is an easy way to write files.
add a memeber variable e.g. CStdioFile m_fLog;
Open or create the file if it doesn't exist:
//open or create logfile for writing
m_fLog.Open("temp.txt",CFile::modeCreate
|CFile::modeNoTruncate
|CFile::modeWrite);
m_fLog.SeekToEnd();//append mode
write to the file (you can write CStrings instead of the constant text below)
m_fLog.WriteString("Hello file\n");
close the file
m_fLog.Close();
You can read the file with m_fLog.ReadString. I hope this helps.
-
May 14th, 2002, 12:19 PM
#4
Re: Help! I can't create a file!
Hej my names is Julian.
And I am also a beginner in visual basic and i think that you should not have so much lines.
Try to make fewer lines.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|