Check if model file exists

Check if model file exists

H.echeva
Advocate Advocate
886 Views
4 Replies
Message 1 of 5

Check if model file exists

H.echeva
Advocate
Advocate

Hello all,

I am creating a macro that batch upload models to the Revit server. But I want to skip files that already exist on the Revit Server. I am trying to check with BasicFileInfo.Extract(path) and then check if is null and encapsulate in a try-catch in case the file doesn't exist. But this is not working. 

Is there an easier way to do this? 

Many thanks

0 Likes
Accepted solutions (1)
887 Views
4 Replies
Replies (4)
Message 2 of 5

recepagah12
Advocate
Advocate

Can't you simply get all file names(Include that exist in the server) and compare them with the name of files that already exist in the server. This looks like a simple comparison test.

0 Likes
Message 3 of 5

H.echeva
Advocate
Advocate

the problem is that as it is in the Revit server normal Windows system methods don't work. For example I can't get the files in the server with "GetFiles" or "File.Exist". If this was done locally in our file based server it would be very easy.

0 Likes
Message 4 of 5

recepagah12
Advocate
Advocate
Accepted solution

What do you mean exactly with "Server", is it BIM360, an external database or your company's local database?

I don't get it, how you can upload a file but can't get the information of uploaded files? If everything seems impossible for now, I can suggest you create a log file that contains every information(Path, name etc.) obtained by BasicFileInfo and save it to log file. This solution is applicable even you can't get the name of the fille in the server.

Hope that helps,

Recep.

Message 5 of 5

H.echeva
Advocate
Advocate

Hello,

Yes I guess I could create a txt external file with all the uploaded files and then compare with that list. That would work. thanks!

0 Likes