LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Folder rename.

Hi,

Does anyone know how to rename folders (Win98/CVI5.5)?

Regards,

John Cameron.
0 Kudos
Message 1 of 3
(3,189 Views)
Hi,

You can use the function "rename" from ANSI C library.
As an example, create a folder named "Test" on your C drive ("C:\Test") and run the following code in Interactive Execution Window:

#include
#include

char OldDirPath[MAX_PATHNAME_LEN];
char NewDirPath[MAX_PATHNAME_LEN];
int status;

strcpy (OldDirPath, "C:\\Test");
strcpy (NewDirPath, "C:\\RenamedDir");

status = rename (OldDirPath,NewDirPath);


After executing this code, the previously created folder (named "Test") will be renamed in "RenamedDir".

Beware that on MS Windows, this function fails if the "OldDirPath" and "NewDirPath" do not refer to the same disk drives.


Regards,
Silvius
Silvius Iancu
0 Kudos
Message 2 of 3
(3,189 Views)
RE Folder rename.,
silvius said;
>Hi,
>
>You can use the function "rename" from ANSI C library.
>As an example, create a folder named "Test" on your C drive
>("C:\Test") and run the following code in Interactive Execution
>Window:
>
>#include
>#include
>
>char OldDirPath[MAX_PATHNAME_LEN];
>char NewDirPath[MAX_PATHNAME_LEN];
>int status;
>
>strcpy (OldDirPath, "C:\\Test");
>strcpy (NewDirPath, "C:\\RenamedDir");
>
>status = rename (OldDirPath,NewDirPath);
>
>
>After executing this code, the previously created folder (named
>"Test") will be renamed in "RenamedDir".
>
>Beware that on MS Windows, this function fails if the "OldDirPath" and
>"NewDirPath" do not refer to the same disk drives.
>
>
>Regards,
>Silvius
Thanks, I'll try that on Monday.

--
John Cameron.
0 Kudos
Message 3 of 3
(3,189 Views)