Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if a file exists?

Status
Not open for further replies.

laserablaatio

Mechanical
Oct 23, 2006
18
FI
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.
 
Replies continue below

Recommended for you

You can use the code

Code:
/directory,names,file_name,file_extention,file_path
*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

 
You may want to check out TCL/TK documentation/examples.
 
Hi,

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
 
Hi cbrn,

what kind of Ansys directives do you mean? I have never understood, why sometimes the /directory comand is not working...

Regards,
Alex
 
Hi,
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.
 
Thanks cbrn. All this limitations are known to me. My ploblem is more complicated. Ansys refuses to work with some files. Till now I did not find any reasons for that. The /directory comand issues a warnig like "Could not acces this file". After that, the comand dose not work for all kind of files. To remediate this, I must restart Ansys!

Pretty strange, I must say...

Regards,
Alex
 
Hi,
it's only an hypothesis: are the "inaccessible" files in a directory which doesn't have "SYSTEM" among the allowed read/write "users"?

Regards
 
Thanks cbrn for the effort! You could have write. I think it should be the read/write thing... But I already checked the files an there are all "read only". So there should be no problem since the /directory command only reads. Also since all files are read only, there is no reason why some file can be read and some of them not...

Regards,
Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top