Daklu Posted September 22, 2009 Report Share Posted September 22, 2009 I have an app that saves various types of configuration files in xml format. To avoid mixing the different types of configuration files, I have different default directories for each type. For simplicity, I use the Read/Write to XLM File VIs and let the user select the correct file via the automatic dialog box. To get the correct default directory to show up when the dialog box opens I've been trying to use the Get/SetDefaultDirectory functions in kernal32.dll. Problem 1: The string returned by the second GetCurrentDirectory call is only showing the drive letter, even though the function is reporting many more characters being written. Problem 2: The SetCurrentDirectory call reports an error but checking the error code turns up nothing. Problem 3: The vi occasionally crashes LV. I think I have all my call parameters set up correctly... Any ideas? Set Current Directory.vi Quote Link to comment
Daklu Posted September 22, 2009 Author Report Share Posted September 22, 2009 (edited) Figured it out... sort of. Since these are the Unicode versions of the functions I need to manually convert the strings to 16-bit arrays. Unfortunately it looks like Labview stores the current directory internally rather than using OS calls. No matter how much I change the current directory the XML dialog box defaults to the last directory used from within Labview. Edited September 22, 2009 by Daklu Quote Link to comment
Phillip Brooks Posted September 22, 2009 Report Share Posted September 22, 2009 (edited) Unfortunately it looks like Labview stores the current directory internally rather than using OS calls. No matter how much I change the current directory the XML dialog box defaults to the last directory used from within Labview. Are you using the 'Write to XML File' function from the palette? If you look inside, it calls vi.lib\_oldvers\_oldvers.llb\Open_Create_Replace File.vi with nothing wired to start path. You might be able to modify or copy 'Write to XML File' and evaluate the path. If it points to an existing folder, pass the folder to the start path and pass a null path for the file. I think this should force the dialog to start where you want it to. Now if we could just get NI to update their own VIs; to bad they don't have interns and some sort of analyzer that they could use to look for old VIs or functions that need to be updated Edited September 22, 2009 by Phillip Brooks Quote Link to comment
Shaun Hayward Posted September 22, 2009 Report Share Posted September 22, 2009 Could you launch your own file browse dialog before the XML function? That way you could hard code your start path etc and simply path the path output from the dialog as the input for your XML functions: Shaun 1 Quote Link to comment
Daklu Posted October 3, 2009 Author Report Share Posted October 3, 2009 Could you launch your own file browse dialog before the XML function? That way you could hard code your start path etc and simply path the path output from the dialog as the input for your XML functions: All I can say is... D'oh! Kudos for you - Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.