Problems Moving Certain Folders...

This is a discussion on Problems Moving Certain Folders... within the C Programming forums, part of the General Programming Boards category; I am trying to develop this program for a friend, but I've hit a problem: folders on his computer won't ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    15

    Problems Moving Certain Folders...

    I am trying to develop this program for a friend, but I've hit a problem: folders on his computer won't move from his C:\ to his Y:\ drive (The Y drive is a folder on his network located on a different computer).

    If I have a normal .txt file and a folder on his desktop, I can move both to another location on his computer without a problem. However, when I try to move them from the desktop to the Y:\ drive, the .txt file (and any file that is not a folder for that matter) WILL move, but the folder will not. I've tried to create other folders in various locations of his harddrive, but still nothing.

    Is this my program? Or is it something perhaps with his network? I'm really not sure what the root of the problem is...? It only affects the folders.

    I'm using the MoveFile() function to move the files... I'm not sure what code to post, it seems to work perfectly until it moves a folder to a different drive.

    Thanks in advance for any help, I really appreciate it.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,782
    Well, if MoveFile fails, it sets the last error, so fetch it with GetLastError and post it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    What operating system is running on the computer that hosts the Y: drive? Windows Vista has complicated permissions that might allow someone to enable file creation but disable folder creation. Can you create a folder there by hand from explorer?

    Can you create folders with your code on the C: drive?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    15
    Turns out the other drive is actually on the same computer. Sorry about that...
    The computer is running Windows XP Professional.

    Yeah, I can move folders and their contents on the C drive with my code without a problem. Folders don't want to move to the Y:\ drive, though. Individual files will, but folders... nope.

    Elysia, I'm unfamiliar with GetLastError... does it return an integer value? If so, when I move an individual file the value returned is 0, and if I move a folder I recieve a 5. The program doesn't crash or anything, the file just doesn't move.

    Thanks

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    http://msdn2.microsoft.com/en-us/library/ms681382.aspx
    Quote Originally Posted by Error #5
    Access is denied.
    MoveFile() can't move folders across drives,
    Quote Originally Posted by http://msdn2.microsoft.com/en-us/library/aa365239.aspx
    The one caveat is that the MoveFile function will fail on directory moves when the destination is on a different volume.
    In other words, MoveFile() is crap.
    Last edited by zacs7; 12-15-2007 at 11:15 PM.

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    15
    Should I use just FileCopy and then FileDelete? What kind of function would allow me to move it to another volume?

    I tried MoveFileEx (http://msdn2.microsoft.com/en-us/library/aa365240.aspx) but that doesn't seem to work, either. Same error: Access Denied. Thanks for letting me know what the 5 represents.

    Code:
    //doesn't work... 
    MoveFileEx(original, destination, MOVEFILE_COPY_ALLOWED);

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    I dunno... perhaps try move each file in the folder and create the directories on the other drive.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,782
    The only safe one is SHFileOperation. Tricky, but yes, it works.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by zacs7 View Post
    In other words, MoveFile() is crap.
    LOL. Nice conclusion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Object not moving to angle
    By mike_g in forum C Programming
    Replies: 1
    Last Post: 06-22-2007, 09:30 AM
  2. openGL space shooter problems
    By c_young in forum Game Programming
    Replies: 0
    Last Post: 01-17-2007, 03:33 PM
  3. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 05:35 AM
  4. Problems moving from Borland to Visual Studio
    By SmashBro in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2002, 04:03 PM
  5. Allegro problems, moving circle leaving trail
    By Da-Spit in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2002, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21