Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Unable to copy directory

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Resolved [RESOLVED] [2005] Unable to copy directory

    Hi!

    I am very annoyed with a problem I have when trying to copy a directory.

    In my application folder I have a structure like this

    MyApp\Comp1\bin\Debug
    MyApp\Comp1\Init
    MyApp\Comp1\Data
    MyApp\Comp1\Archive
    MyApp\Comp2\bin\Debug

    etc...

    WHen someone drops a certain file in the Init directory I want first archive the entire Data directory to the Archive folder, creating a folder like:
    Archive\Data_2008-09-27\

    But the problem is, in order to do this I need to know the full path of the Data and archive folders. I tried to do this:

    Application.StartupPath +"\..\..\Data"

    But the the My.Computer.FileSystem.CopyDirectory method complains about a bad path. I assume it can't handle the \..\ Is there a better way to get the path only to the MyApp1\ level?

    like c:\Apps\MyApps\MyApp1

    Anyone has a solution to this? It should be simple... I just want to know the AppRoot path...

    Note this is Winforms, not ASP.NET

    And I dont want to do string parsing... feels sooo vb6

    kind regards
    Henrik

  2. #2
    Lively Member
    Join Date
    Jul 2008
    Posts
    107

    Re: [2005] Unable to copy directory

    MrNorth,

    Does this do what you need?

    Code:
            Dim myPath As String = Application.StartupPath
    
            myPath = Directory.GetParent(myPath).FullName
            myPath = Directory.GetParent(myPath).FullName
            myPath = myPath & "\Data"
    
            MsgBox(myPath)
    Kerry Moorman

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [2005] Unable to copy directory

    One of these?


    Code:
            Dim SpecFolder() As String = New String() _
            {Environment.GetFolderPath(Environment.SpecialFolder.System), _
             Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), _
             Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), _
             Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), _
             Environment.GetFolderPath(Environment.SpecialFolder.Desktop), _ 
             Application.ExecutablePath}
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Unable to copy directory

    You can use the Path class to manipulate file and folder paths. If you've got a folder path and you want the path of its parent then Path.GetDirectoryName will get it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: [2005] Unable to copy directory

    Thanks that solved it!

    kind regards
    Henrik

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