Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 73,272 times

Contents

Related Categories

Files and Folders - Folder Operations

Folder Operations

There are also VB functions that allow you to rename, create and remove directories (called folders in Win 95/98). These are:

Name

Description

MkDir

Creates a directory

RmDir

Removes a directory

Name

Renames a directory

To create a directory, you use the MkDir function:

MkDir DirNameandPath

So,

MkDir "C:\testdir"

creates the directory testdir (so long as it does not already exist)

To remove a directory, you use the RmDir function:

RmDir DirNameandPath

So,

RmDir "C:\testdir"

removes the directory testdir (so long as it is empty)

To rename a directory, you use the Name Function:

Name OldNameandPath As NewNameandPath

So,

Name "C:\testdir" As "C:\testdir2"

Renames testdir as testdir2.

If you want to know how to do these operations using Win API, which allows you to send files to the recycle bin, and display the standard file copying dialog, click here.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • help

    Posted by tieungao35 on 09 Nov 2005

    Hi all,
    I am a new beginner of Visual basic 6. Even though i read James's article, i don't know how to create a project and add his code as a new module.
    Could you please show me how to create 1...

  • INI files

    Posted by TomDooley on 26 Sep 2005

    Hello,

    the article of James is not state of the art.
    To import win32 functions is not the way how you should work with the .NET framework. With a little bit pation you can write a own managed code...

  • Copying folders including subdirectories

    Posted by kingman29 on 07 Jul 2005

    I am using deppfreeze in my internet cafe.This program protects hard drive from every changes and does not allow save games.When computer restarted all saves dissapear from hard drive.I know the game...

  • ei.

    Posted by po_tph on 20 Mar 2005

    do you a source code of hing folders???

  • hide folder source code???

    Posted by po_tph on 20 Mar 2005

    can anybody plz help me i want to have a sourcec code of hidng folders in windows directory.thanks