How to check if a file exists?
How to check if a file exists?
(OP)
Hi all,
could not find in the APDL documentation, if it is possible to somehow check if a file exists or not. Could then do branching based on this information. Any hints?
I'm using Ansys 9.0.
Thanks.
could not find in the APDL documentation, if it is possible to somehow check if a file exists or not. Could then do branching based on this information. Any hints?
I'm using Ansys 9.0.
Thanks.





RE: How to check if a file exists?
CODE
*get,numfiles,parm,names,dim,3
If numfiles is 0, then file is not existing.
But! I had some problems with the /directory comand. Sometimes for some files on some PC's I get some error like "Could not acces this file".
Regards,
Alex
RE: How to check if a file exists?
RE: How to check if a file exists?
Mihaiupb's suggestion is great, and I think it won't work correctly only in the case that the directory and/or the filename doesn't respect Ansys' directives (which are greatly more stringent wrt Windows/Unix).
Regards
RE: How to check if a file exists?
what kind of Ansys directives do you mean? I have never understood, why sometimes the /directory comand is not working...
Regards,
Alex
RE: How to check if a file exists?
I don't remember all of them right now, but there is a limitation on the number of characters for the complete path+filename (248 char.s), other on the number of characters on the filename alone (32 bytes I seem to remember, but I may be wrong); if the path is the default one, then all available 248 char.s can be used for the filename. Extensions must be at most 8 bytes long, and Ansys can handle files with multiple extensions (such as myfile.v1.db) but in this case I don't know how the char counting behaves...
I also suspect there is some limitation in the number of sub-branches in a directory structure...
In order to be sure I never run into such problems, when the seed directory structure seems too complicated, I brutally duplicate it directly in "C:\" (shortest path possible!).
Blanks are allowed in path and filename, but then the path+filename must be enclosed in single quotes.
RE: How to check if a file exists?
Pretty strange, I must say...
Regards,
Alex
RE: How to check if a file exists?
it's only an hypothesis: are the "inaccessible" files in a directory which doesn't have "SYSTEM" among the allowed read/write "users"?
Regards
RE: How to check if a file exists?
Regards,
Alex
RE: How to check if a file exists?