Re: Moving a file from A to B fails with incorrect syntax error

Tech-Archive recommends: Speed Up your PC by fixing your registry



See below...
On Thu, 26 Jun 2008 15:35:06 +0100, "Tony" <lazyherbert@xxxxxxxxxxxxxxxxxx> wrote:

Hi Tom,

I have tried all of the suggestions, i.e. copy and delete etc, but the file
will not move.
I have renamed the destination to be a single folder off of the root and
with no spaces. I have rebooted my PC.
****
Why in the world would you think a reboot would solve this?
****
I have even renamed the extension from .wav to .tmp but all to no avail.
The .wav files I want to move will not budge, but .txt files in the same
folder with the same attributes and permissions will move to the same
destination folders.
I am the only account on my Vista PC, with full administrative rights BUT it
wont go.

Is it possible that because my app is running as a service that it fails?
****
WHY WAS THIS NOT STATED IN THE FIRST MESSAGE? How can we be expected to diagnose problems
when you don't give us critical information on which the entire answer might depend?

Have you tried executing this code from a test program which is running as your login
account? That would have been the first suggestion I would have made; if it works as a
console app but not in a service then it is clear that the failure is that you have a file
that is not accessible from a service. Try that first.
****

If I didnt have other things to do on my project I would have pulled all of
my hair out by now!!!
****
When asking a question, you must supply ALL necessary information, such as the code, the
fact that it is in a service, and other information which is absolutely critical to the
analysis.

Are you sure that logical drives like c: and d: are actually defined for the service?

Assume that unless you have installed the service to log in as you, that you are having
problems with access rights. Try running a sample from a simple console app. THEN if
there is a problem, you know it is fundamental to the API involved, but if you don't, it
is a consequence of running in a service.
****

It seems so simple, and I ma sure it is, but I cant seem to find the answer.
****
Unless you have created the service to log in as you, the service runs as a LocalSystem
account, which has very limited context in which it is running. Concepts like logical
device names are among the first things to go.
joe
****

TIA

Tony
"Tom Serface" <tom.nospam@xxxxxxxxxxxxx> wrote in message
news:01CE9C25-DA6A-44CA-8960-B9DB23FE8015@xxxxxxxxxxxxxxxx
Is there a chance the .wav file is opened in another application (like
does some application running use it for one of the sounds it produces and
just keep it open)?

Just for the sake of argument, have you tried using CopyFile() and
DeleteFile() individually to see if that works?

One last thing, are you sure that location b doesn't already have a file
with that name? I think you could use the MOVEFILE_REPLACE_EXISTING to
write over existing files.

Tom

"Tony" <lazyherbert@xxxxxxxxxxxxxxxxxx> wrote in message
news:%23ynci541IHA.1772@xxxxxxxxxxxxxxxxxxxxxxx
My code is posted below, BUT it seems that the issue is with the file
extension because the code will quite happily work with text files in the
same folder, but will not move (or incidentally copy) the files. When I
try I am getting the
following error message
failed with error 123: The filename, directory name, or volume label
syntax is incorrect."

I can manually copy / cut and paste the .wav files

My code snippet -

CString csFile1 = "c:\\location a\\subdir\\subsubdir\\file.wav";
CString csFile2 = "c:\\location b\\subdir\\subsubdir\\file.wav";
if(MoveFileEx(csFile1, csFile2, MOVEFILE_COPY_ALLOWED))
{
WriteStringToFile(csFile2 ); //my own function which never gets
called
}
else
{
TCHAR szBuf[80];
LPVOID lpMsgBuf;
DWORD dw = GetLastError();
LPTSTR lpszFunction = "";

FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );

wsprintf(szBuf,
"%s failed with error %d: %s",
lpszFunction, dw, lpMsgBuf);

WriteStringToFile(szBuf);

LocalFree(lpMsgBuf);

}
"David Wilkinson" <no-reply@xxxxxxxxxxxx> wrote in message
news:upVNtc41IHA.4912@xxxxxxxxxxxxxxxxxxxxxxx
Tony wrote:
Hi,

I am moving a file from c:\location a\subdir\subsubdir\file.wav to
c:\location b\subdir\subsubdir\file.wav

but the error message i get is

"failed with error 123: The filename, directory name, or volume label
syntax is incorrect."

I am running on a vista home premium machine, using visual studio 6 if
that helps.

Tony:

Shouldn't you be showing us some code?

--
David Wilkinson
Visual C++ MVP


Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: [SLE] Files modified while copying from USB-card
    ... The card is automounted and not touched while the script is ran. ... That error message, as cryptic as it is, seems more like what you'd get ... The destination is freshly made at each pass by the script. ... It creates a folder 'yymmdd.xx' where 'xx' is an incremented sequential ...
    (SuSE)
  • RE: Switch from Power User to User
    ... they got an error message regarding Folder ... The SBS\\Users on SBS is the folder that is attempting to sync. ... All the workstations that have users that have been changed from Power User ... > Synchronize, how many offline folders you can see in the Items to ...
    (microsoft.public.windows.server.sbs)
  • RE: Offline Address Book error on send/receive
    ... address book can not be download error message after you joined the SBS ... navigate to the server entry. ... Please rebuild Offline Address Lists to see if it helps. ... Storage Group -> Public Folder Store, Does the store is mounted properly? ...
    (microsoft.public.windows.server.sbs)
  • Re: BTS 2006 FTP Adapter spooling permissions
    ... Did you say you have 2 FTP send port pointing to the same FTP location? ... folder, not to mention same output file. ... when move from"spooling folder to destination folder", ... TemporaryFolder: destfolder/tmp ...
    (microsoft.public.biztalk.general)
  • Re: Help with VBA for document formatting.
    ... but nothing changed - the result was the same error message. ... Applications Folder. ... Python, b. ... ...will put 1 tab stops in Body Regions;A01 ...
    (microsoft.public.mac.office.word)