Reply

AddBlockByFile fails when file has underscore, only on 1 system

[ Edited ]

I created a program with wpf and c# to do a batch replace of a block of a certain name in multiple draft files. I was almost finished with the program, and doing some error handling, when all of a sudden it started failing at the point where I use the SolidEdgeDraft method AddBlockByFile. On my dialog I have a label that shows the new block name only (takes the full path from open file dialog and takes away the path and extension and only leaves the file name). So I noticed at this point that if the block file name has an underscore it is taken out in the label on the dialog. So I tried running the program, renaming the file to take out the underscore, and it works. This doesn't make sense to me because even though the format of the label sees an underscore as an accelerator key and takes it out, nothing in my program reads the label, I only read the string variable which debugging tells me still has the underscore. The other strange thing is that it only does this on the computer I created the program on. I tried running the same exact release version on the problem computer as well as another computer and it works on the other even when the file has the underscore but not on the computer I created the program on. I thought maybe something was corrupt with visual studio, I tried uninstalling and reinstalling Visual Studio Express as well as the .net frameworks, and no success. Any ideas?

3 REPLIES

Re: AddBlockByFile fails when file has underscore, only on 1 system

The problem wasn't the underscore, the dft file I was using to import as a block in my tests, accidentally had a block inserted into it that had the same name as the file and it was causing an error. The version I was using on the other test computer was older and didn't have this block inserted. I thought it had to do with the underscore because the first time the error happened I noticed for the first time that the label was taking the underscore out, but this is a formatting thing for wpf labels because the underscore is used as an accelerator key.

Re: AddBlockByFile fails when file has underscore, only on 1 system

Glad you figured it out. I was rather stumped as to why you were seeing the issue.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: AddBlockByFile fails when file has underscore, only on 1 system

I finally tried renaming the file to anything else, instead of just taking out the underscore, and found out that any other name worked, then I opened the file and saw a block inside that had exactly the same name as the filename. It must have happened because in one of my tests I picked the dft file in both places, as the block to insert, and the dft file to insert into.