From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a Locked File

I have a data compiling utility that gathers data files created by various programs and organizes it in a coherent way. So far, the only way I know how to get data from these files without causing write errors with their host programs is to create a copy and then read the copy. This workaround works pretty well but I'm concerned it may lead to HDD problems down the road with near-constant creation and deletion of these data files.

 

I thought maybe another way to do it would be to copy the entire file into memory (as opposed to disk) and then read that but I wouldn't know where to begin.

 

Has anyone encountered this issue before?

0 Kudos
Message 1 of 6
(3,002 Views)

Just open it with read-only access.

0 Kudos
Message 2 of 6
(2,979 Views)

How big are the files?  What are the other programs doing? Are you trying to read them while the other program still has them open and writing to them?  That is why the other programs would be locking the files.

 

Why do you think that copying the files would cause hard drive problems?

 

I'm not sure what you mean by copying the entire file into memory.  Do you mean one program puts it into memory then allows another program to access that memory?  That is very likely impossible, and if it is possible, far more complicated and risky than other options.

0 Kudos
Message 3 of 6
(2,977 Views)

@RavensFan wrote:

How big are the files?  What are the other programs doing? Are you trying to read them while the other program still has them open and writing to them?  That is why the other programs would be locking the files.


Some of the files can get up to 30MB. The other programs are continually adding data to these files. Yes, I'm trying to read them while the other program still has them open and writing to them. I understand why they are locked and I don't have access to the source code of these programs.

 


Why do you think that copying the files would cause hard drive problems?

Excessively writing data: Copy 30MB file, read copy, delete copy, repeat for many weeks every second or so (and for several different data files).

 

I'm not sure what you mean by copying the entire file into memory.  Do you mean one program puts it into memory then allows another program to access that memory?  That is very likely impossible, and if it is possible, far more complicated and risky than other options.


I was thinking instead of copying the file to a physical disk space on the hard drive--as I'm doing now--perhaps it could be copied into a memory space instead. From there, I can read the copy in memory and release it, saving undue wear and tear on the HDD.

 

 

 

0 Kudos
Message 4 of 6
(2,970 Views)

I wouldn't worry about hard drives.  The OS puts far more wear and tear on the hard drive than what you are talking about, and hard drives last years.  Perhaps a solid state hard drive may have issues in that they have a finite number of write cycles they can take, but you'd have to look at the specs for them and do the math to see how much data you are actually writing.  Think about how much data is constantly being written to server class hard drives and you rarely hear about them failing.

 

And how would you copy data into a memory space to be read elsewhere (assuming it can be done), if you don't have access to the source code to have it write to memory instead of the hard drive?

 

I think BowenM's idea of opening with read-only access might work.  I have never tried to do something like that myself to know if it does.  I don't know if locking a file blocks all access to a file, or just the ability to write new data to a file.

 

 

 

 

0 Kudos
Message 5 of 6
(2,963 Views)

@RavensFan wrote:

And how would you copy data into a memory space to be read elsewhere (assuming it can be done), if you don't have access to the source code to have it write to memory instead of the hard drive?


Right now, I'm using the "Copy" primitive from the File I/O palette in my own program to non-invasively access the data files. I'm not trying to get the other programs to save data in a different way. I'm exploring different ways that I can access that data. But the impetus for wanting to copy to memory instead of disk was to coddle the HDD ... so if HDD wear is not an issue I guess it's a moot point.

0 Kudos
Message 6 of 6
(2,950 Views)