02-22-2013 04:37 PM
Hello, I know its probably a silly question but im having trouble writing to a file within the project folder. By default it saves it inside the project folder but im trying to save it to another directory called Results. The following is an example of what im trying to do.
strcpy(path, "\Results\");
sprintf (buf,"%lu.txt ", (time));
strcat(path, buf);
file = OpenFile (path,VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_ASCII); /* Create and write to file.*/
This seems to always give me errors in opening the file. Thanks
02-22-2013 06:27 PM
If you're only using one backslash, then you're potentially inserting a carriage return into your path ("\r"), since backslash is an escape character. If you want a literal backslash, you need to use two blackslashes, i.e.
strcpy(path, "\\Results\\");
Also, I would recommend using the full path. You can get the project directory using GetProjectDir() and build your path out of that. CVI maintains a currect active directory for your project for relative paths, which is usually the project directory - but the active directory can be changed by other parts of the project code so I wouldn't count on it.
02-22-2013 06:32 PM
Yeah i just found that function and it works great! thank you