Jump to content

Problem with File Info (does not work to set Folder dates)


Recommended Posts

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

Link to comment
  • 4 weeks later...

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).

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.