CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    3

    [RESOLVED] Move file - Delete empty directory failing

    I am trying to move a single file out of a folder to the desktop and then delete the *empty* folder using VB6 (WinXP). I keep getting a file access error 75.

    The file I am moving will always have a known prefix and.txt extension but the complete name will change and be unknown at design time.

    The bare-bones code that is failing is:

    pth = Environ("HOMEPATH") & "\desktop\Test"
    pth2 = Environ("HOMEPATH") & "\desktop"
    f = "\" & Dir(pth & "\t*.txt")

    Name pth & f As pth2 & f
    RmDir (pth)

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Move file - Delete empty directory failing

    Explain more about what it is you are doing? And, WHY?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Move file - Delete empty directory failing

    Have you checked MSDN
    During a file-access or disk-access operation, for example, Open, MkDir, ChDir, or RmDir, the operating system couldn't make a connection between the path and the file name. This error has the following causes and solutions:

    * The file specification isn't correctly formatted.

    A file name can contain a fully qualified (absolute) or relative path. A fully qualified path starts with the drive name (if the path is on another drive) and lists the explicit path from the root to the file. Any path that isn't fully qualified is relative to the current drive and directory.
    I'm almost sure it's because theres no drive spec in the dir's...

    have you tried
    Code:
    pth = Environ("HOMEDRIVE") & Environ("HOMEPATH") & "\desktop\Test"
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #4
    Join Date
    Mar 2011
    Posts
    3

    Re: Move file - Delete empty directory failing

    Thanks for your reply. I finally got it working after spending all day on this stupid thing. It wasnt the drive letter, it was the dir that was locking the folder. after moving the file I had to do another dir so that VB could see that the directory was empty.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured