Bob Schor Posted October 9, 2014 Report Share Posted October 9, 2014 I am trying to programmatically set the "Last Modified" date on a bunch of folders. I've seen three methods to do this: two use .NET calls to mscorlib.system.io.directory or .directoryinfo, and one uses the OpenG File Info function. None of these methods work for me (Windows 7 (x64) with LabVIEW 2012, 32-bit). The .NET routines generate Error 1172, "Error calling static method System.IO.Directory.SetLastAccessTime, (System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. Inner Exception: System.IO.IOException: The process cannot access the file 'D:\BS\Documents\LabVIEW\Labs\B-Lab\Set Folder Dates\Test Folder' because it is being used by another process.) <append><b>System.IO.IOException</b> in Folder Write Time.vi" The OpenG File Info function doesn't give me an error, but neither do it modify the Modification Date (or the Creation Date) of a folder (though it works fine for files). Anyone have any idea what is going on, and/or how to fix this? I've attached the code I used to test this out. Bob Schor Test File Info.vi Quote Link to comment
SDietrich Posted October 9, 2014 Report Share Posted October 9, 2014 I tried your VI and it doesn't work for me, either (LV2013). You could try to use Win32-API SetFileTime(), it looks pretty straight forward. Quote Link to comment
Bob Schor Posted November 2, 2014 Author Report Share Posted November 2, 2014 Not only did I figure this out, but I am currently using it to reset the dates of 150,000 folders (I copied a backup of my Laptop from one Archive drive to another) -- it's not the fastest process (it does on the order of 50 folders/second), but it's "hands-off". As noted here and in the LabVIEW Discussion Forums, using the .NET calls in Windows 7 and attempting to do multiple files can lead to difficult-to-understand (and thus hard to program-around) errors. The technique that I used was to arrange things so that the only file I/O that was taking place was on the Target device whose Folders I was trying to modify. My routine requires two passes -- during the first pass, LabVIEW parses the Source Folder Tree and writes a text file containing the Folder Path and the Creation, Modification, and Accessed TimeStamps. The second pass reads (and closes!) this file, then applies all of the changes to the Target Folder Tree (assumed to mirror the Source Tree, which is the case as we used Windows to copy the Source Tree to the Target Tree). 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.