Error when setting PCAN_TRACE_LOCATION for same folder multiple times

The free CAN Software API (Application Programming Interface) for Windows®
Post Reply
PranavBodke
Posts: 1
Joined: Tue 20. Jan 2026, 06:28

Error when setting PCAN_TRACE_LOCATION for same folder multiple times

Post by PranavBodke » Tue 20. Jan 2026, 10:04

Hello Team,

I am facing an issue while configuring the trace file location using PCAN-Basic API.

When I set TPCANParameter.PCAN_TRACE_LOCATION to a specific folder for the first time, it works correctly.
However, when I try to set the same folder again, the API returns an error.

Code snippet:

Code: Select all

ushort channelUsed = PCANBasic.PCAN_USBBUS1;
string tracesFolder = System.IO.Path.GetTempPath();
string fullPath;

fullPath = System.IO.Path.Combine(tracesFolder, "PCAN-Basic_Flashing");
System.IO.Directory.CreateDirectory(fullPath);

if (PCANBasic.Initialize(channelUsed, TPCANBaudrate.PCAN_BAUD_500K) == TPCANStatus.PCAN_ERROR_OK)
{
    if (PCANBasic.SetValue(
            channelUsed,
            TPCANParameter.PCAN_TRACE_LOCATION,
            fullPath,
            (uint)fullPath.Length) == TPCANStatus.PCAN_ERROR_OK)
    {
        Console.WriteLine("Trace location set successfully");
    }
    else
    {
        Console.WriteLine("Error while setting trace location");
    }
}
Observation:
- First time setting trace location → Success
- Setting same folder again → Error

Is PCAN_TRACE_LOCATION required to be set only before Initialize()?
Is Uninitialize() required before setting it again?

Any guidance would be appreciated.

Best regards,
Pranav Bodke
Last edited by F.Vergnaud on Fri 23. Jan 2026, 15:15, edited 1 time in total.
Reason: code formatting

M.Maidhof
Support
Support
Posts: 1770
Joined: Wed 22. Sep 2010, 14:00

Re: Error when setting PCAN_TRACE_LOCATION for same folder multiple times

Post by M.Maidhof » Tue 20. Jan 2026, 10:37

Hi,

which version of the PCANBasic API and driver do you use?

regards

Michael

Post Reply