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

Posted on 2003-04-01
Medium Priority
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:


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


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,

Question by:RKulwiec
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 12

Expert Comment

ID: 8247949

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

Author Comment

ID: 8247977
Yes.  c is zero terminated.
LVL 12

Accepted Solution

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.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

800 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