Creating folders by changing logging set strFileName


patrickokeeffe

Recommended Posts

I'm using a sequence to change the strFileName variable of several logging sets in order to create new logging files every hour. It would be very advantageous to create new folders also so hourly files could be grouped together. I thought adding the non-existent folder name plus "\" prior to my new file name in the strFileName would generate a new folder but I got a C1013 error instead. Is there a technique through which I can accomplish this? Any input? Much thanks

Link to comment
Share on other sites

No, we try not to let DAQFactory do too much thinking for you. Letting a program, especially one connected to real world hardware, make assumptions and do too much automatically is just asking for problems.

Anyhow, you can easily create the directories on your own using File.MakeDirectory(). It just takes a string with the directory to create (you should probably specify the full path). Note that if you are creating a subdirectory, you have to create the parent first.

Link to comment
Share on other sites

  • 2 months later...

Follow up question

It's true that File.MakeDirectory() will create a directory for me but it also returns an error C1125 if the directory already exists and there doesn't seem to be a way of checking for existence before-hand. I've been using Ignore statements so far but now I'd like to verify some folders exist and prompt the user if they don't. A function analogous to File.GetFileExists would be awesome - seems this is probably best done using try-catch though?

Link to comment
Share on other sites

I exercised File.getFileExists() in a blank document and found trailing slashes trip it up - it will indeed recognize a directory sans backslash. I typically store paths with the slash in place which explains why I couldn't get it to work so now I'm using the following with success. Thanks for the tip!

File.getFileExists(Left(dirPath,GetLength(dirPath)-1))

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.