patrickokeeffe Posted August 6, 2010 Share Posted August 6, 2010 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 More sharing options...
AzeoTech Posted August 6, 2010 Share Posted August 6, 2010 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 More sharing options...
patrickokeeffe Posted November 2, 2010 Author Share Posted November 2, 2010 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 More sharing options...
AzeoTech Posted November 2, 2010 Share Posted November 2, 2010 I believe getFileExists() will actually work with directories. Have you tried it? It seemed to work for me under Win 7 x64. If it doesn't, you would have to use try/catch. Link to comment Share on other sites More sharing options...
patrickokeeffe Posted November 3, 2010 Author Share Posted November 3, 2010 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 More sharing options...
AzeoTech Posted November 3, 2010 Share Posted November 3, 2010 That makes sense. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.