LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get the directory(or folder) name?

Hello. I want to get directory name using Labwindows CVI. For example, my 😧 drive has 'aaa', 'bbb', 'ccc' directory(or folder),
and I want to get the directory name in specific folder using some function? Is there any function knowing the dirctory name?
0 Kudos
Message 1 of 5
(5,862 Views)
Hello,
Please take a look at the function named "GetDir". This function gets the current working directory.

Also, the function "GetProjectDir" function gives you the directory in which the current project is present.

You may go to LabWindows/CVI help and search for all the functions related to dir or folder and see which one suits you the most.

Sastry, V.
Applications Engineer
National Instrumentsto
0 Kudos
Message 2 of 5
(5,862 Views)

Old question, but still relevant. 

 

I have the same question, but have not found the solution. E.g. when connecting an USB memory stick it will appear with a name, often when new, brand name of the USB memory. I want to look for a specific name.

 

I can’t find this with GetDir() 

 

Regards,

Gerhard

Message Edited by *Gerhard* on 06-14-2010 04:27 AM
Message Edited by *Gerhard* on 06-14-2010 04:27 AM
0 Kudos
Message 3 of 5
(5,380 Views)
I'm not sure if you can get this information using a CVI library function, but you can certainly use the Windows API function GetVolumeInformation().
--
Martin
Certified CVI Developer
0 Kudos
Message 4 of 5
(5,375 Views)

Yes !

 

Thanks,  it worked !

 

Gerhard

 

 

 

 

Code:

______________________________________________________________________

 

int CVICALLBACK FindUSB (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
    int Loop, Result, CurrentDrv, NumberOfDrv;
    char DirName[MAX_PATHNAME_LEN];
 
 
    char  lpVolumeNameBuffer[MAX_PATHNAME_LEN];
    char  lpVolumeSerialNumber[MAX_PATHNAME_LEN];
    char  lpFileSystemNameBuffer[MAX_PATHNAME_LEN];


    switch (event)
    {

        case EVENT_COMMIT:
            for (Loop = 0; Loop <= 25; Loop++)
            {
                Result = SetDrive (Loop);
                printf("SetDrive %2d / %c: %d", Loop, (char) (Loop + 65), Result);
    
                if (!Result)
                {
                    Result = GetDrive (&CurrentDrv, &NumberOfDrv);
                    printf("   GetDrive %c: %d  %d", (char) (CurrentDrv + 65), NumberOfDrv,  Result);
     
                    Result = GetDir (DirName);
                    if (!Result)
                    {
                        printf("   Dir: %s", DirName);

 

                        GetVolumeInformation(    NULL,                                // lpRootPathName,         
                                                                lpVolumeNameBuffer,        // lpVolumeNameBuffer,     
                                                                300,                                 // nVolumeNameSize,        
                                                                NULL,                               // lpVolumeSerialNumber,   
                                                                NULL,                               // lpMaximumComponentLength
                                                                NULL,                               // lpFileSystemFlags,      
                                                                lpFileSystemNameBuffer,  // lpFileSystemNameBuffer, 
                                                                300);                              // nFileSystemNameSize)
      
                        printf("   VolumeName: %s", lpVolumeNameBuffer);
                    }
                }
                printf("\n");
            }
         break;
    }
    return 0;
}

0 Kudos
Message 5 of 5
(5,363 Views)