writing to text file

  • Thread starter jigi via DotNetMonster.com
  • Start date
J

jigi via DotNetMonster.com

i have a compiled dll, and i want to see what values ar in certain methods
during run time. i have built the release build . is there a way to write to
a text file on my desktop or qa desktop?
 
W

William DePalo [MVP VC++]

jigi via DotNetMonster.com said:
i have a compiled dll, and i want to see what values ar in certain methods
during run time. i have built the release build . is there a way to write
to
a text file on my desktop or qa desktop?

Check the docs for SHGetFolderPath() with CSIDL_DESKTOPDIRECTORY. That will
get you the fully qualified path to the desktop folder. Use that to create a
file name.

You have a number of options to create a file name. For example, can use
SetCurrentDirectory() and then GetTempFileName() or _splitpath() and
_makepath().

Once you have a file name, you can create it however you like -
CreateFile(), fopen(), CFile class etc.

Regards.
Will
 
T

Tom Serface

For the most part if you are writing Windows programs I'd use CreateFile,
ReadFile, and WriteFile (or the Ex versions). I just wrote this routine
yesterday (uses MFC sorry) to create a temp file name:

CString GetTempFilePath(LPCTSTR strPattern)
{
CString csPath;
if(GetTempPath(_MAX_PATH,csPath.GetBuffer(_MAX_PATH+1)) != 0) {
csPath.ReleaseBuffer();
CString csTempFile;
if(GetTempFileName(csPath,strPattern,0,csTempFile.GetBuffer(_MAX_PATH+1))
!= 0) {
csTempFile.ReleaseBuffer();
return csTempFile;
}
}
return CString();
}

Using the functions that Will is referring to. It works pretty well
actually.

Tom
 
W

William DePalo [MVP VC++]

jigi via DotNetMonster.com said:
i keep getting error when using vc++.net with fopen

Which one?

Did you try to diagnose the problem looking at errno or strerror()?

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top