Login Page - Create Account

Support Board


Date/Time: Wed, 05 Feb 2025 22:02:00 +0000



Post From: Does anyone know how to format the file pathway for exporting to csv file

[2025-01-31 07:37:23]
seandunaway - Posts: 316
it works for me too, including writing to files outside of the Data directory or with absolute filenames

most likely your sierrachart instance is not being run as an administrator so you don't have write access, to c:\ for example

add a call to sc.GetLastFileErrorMessage() if the open returns false, to know exactly why (e.g. if (!sc.OpenFile(FilePath, n_ACSIL::FILE_MODE_OPEN_TO_APPEND, FileHandle)) sc.AddMessageToLog(sc.GetLastFileErrorMessage(FileHandle), 1);)

2025-01-30 23:34:14.601 | Chart: ESH25-CME [C][M] 5 Min #1 | Study: bars2csv | File error: Windows error code 5: Access is denied. *

also, please remember that string literals in c++ use \ to escape special characters like the \n for newline in your WriteFile arguments. use \\ to insert literal \ (e.g. \\.\C:\Tmp\ is "\\\\.\\C:\\Tmp\\")

use win32 documentation for CreateFile() for how to format paths correctly, especially if you're wanting to place on a network share or other device like your mac
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea

anyway you probably want sc.WriteBarAndStudyDataToFileEx()
Date Time Of Last Edit: 2025-01-31 10:39:55