Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CFile::Write not working properly on a network drive unless I add one to the number of bytes.

Posted on 2003-04-01
6
Medium Priority
?
304 Views
Last Modified: 2013-11-20
I am having a problem writing out to a file on a network drive.  When I call the CFile Write function, the computer hangs for about a minute, then eventally displays an error message that access to the file is denied.  I have write access to the network drive.  This problem only happens when using the network drive.  It works fine when writing to a local drive.  The command I use is:

fp->Write(c,strlen(c));

But the funny thing is, if I add one to the number of bytes being sent, such as:

fp->Write(c,strlen(c)+1);

then it works fine.  Does anybody know why this is?  Has anyone else ever experienced anything like this?

c is a character string.  I have allowed enough space for the string.  I can't find anywhere where I don't allow enough memory.

Thank you,

Ray
0
Comment
Question by:RKulwiec
  • 2
3 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 8247949

  IS c Zero terminated? If not then strlen may return a huge value.
0
 

Author Comment

by:RKulwiec
ID: 8247977
Yes.  c is zero terminated.
0
 
LVL 12

Accepted Solution

by:
williamcampbell earned 1000 total points
ID: 8248047
char we[6] = {"123456"};
int len = strlen (we);

CFile cf;
cf.Open ( "\\\\COMP\\SOMEDIR\\text.txt", CFile::modecreate | CFile::modeWrite );
cf.Write( we, len );
cf.Close ();

Do this test above and see what happens.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question