dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Path/File Access Error

  1. #1
    Join Date
    Sep 2006
    Posts
    104

    Path/File Access Error

    Hi, i am using the dir(), mkdir(), and rmdir() functions to manipulate files on my system. However i am getting an error when i do the following:

    directoryPointer = Dir(App.Path & "\foldername")

    If directoryPointer = "" Then
    MkDir App.Path & "\foldername"
    End If

    if i run this the first time, it creates the file fine, but then if i try call this method again it comes up with the error 'Path/File Access Error' and highlights the mkdir line of code in the debug mode - even though i am telling it that if it already exists then ignore the mkdir function

    also if i try to remove the directory with the rmdir() function it says exactly the same error.

    i am very confused and would greatly appreciate any help

    thanks

  2. #2
    Join Date
    Sep 2006
    Posts
    104

    Re: Path/File Access Error

    i have noticed that it is creating the folders as read only. I am trying to set the attributes for the folder as normal but for some reason it is ignoring them and still creating the folder as read only

    MkDir directoryPath
    SetAttr directoryPath, vbNormal

    has anyone got any suggestions
    thanks

  3. #3
    Join Date
    Aug 2001
    Posts
    1,447

    Re: Path/File Access Error

    since ever call you make results in exactly the same path name, it is never blank and your test says go ahead and make the same one over and over.

    your problem is that using dir has to be done DIFFERENTLY (no parameters) all times but the first time.

    read the help instructions about the dir command.
    phinds
    vs2008, 3.5SP1 Version 9.0.21022.8 RTM

  4. #4
    Join Date
    Sep 2006
    Posts
    104

    Re: Path/File Access Error

    thanks for the reply. I found that i was not saying in the dir what i was looking for, i simply had to use the attribute vbdirectory in the dir() function:

    dir(pathname, vbdirectory)

    then i am asking it to tell me whether it is a directory

    thanks

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)