04-02-2009 03:11 AM
hello,
i have a little problem ans hope everyone can help me.
I would like to open a *.ini file if I press the button, but the file does not open. can somebody please help me?
int CVICALLBACK LoadFile(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
OpenFile("c:\\home\\My Documents\\studium\\File.ini",VAL_READ_WRITE,VAL_OPEN_AS_IS,VAL_ASCII);
break;
}
return 0;
}
Solved! Go to Solution.
04-02-2009 05:01 AM
i am not sure, what do you expect the OpenFile() function to do ?
OpenFile() opens the file in a programmatic manner: it means that it makes available a value (that you should store in a variable) which allows you to read or write data to/from the file bycalling file manipulation functions like ReadFile() or WriteFile(). it will NOT open the file in your favourite editor !
to open the file in the Windows user Interface meaning of the word, use the function OpenDocumentInDefaultViewer().
04-02-2009 05:07 AM
Hi Axinia,
What do you actually want to do when the button is clicked?
Do you want to open a seperate text viewer (like notepad) to see the contents of the file or do you want to read the contents of the file into a string?
The solution depends on your answer.
The code you have provided actually opens a file to be read/written, but you have to assign the return value to a variable in order to access it later.
int fileHandle;
fileHandle = OpenFile (...);
Hope this helps,
04-02-2009 05:21 AM
thx dummy_decoy
exactly this I have looked 🙂