Corrupt Text Files
-
I'm writing a very simple VB .NET application that "monitors" a remote directory (via UNC paths) for a particular data file. The data file is created by a third-party program that creates or appends comma-delimited records to the file. (I think it opens the file, writes the record and then closes the file). My application "wakes up" every few seconds and if this remote file exists, it does the following: 1) Rename the file on the remote directory to minimize possible conflicts. 2) Move the renamed file to the local PC. 3) Process the records in the local file. 4) Delete local file. Pretty simple, I know. But for some reason, I'm getting random "corrupted" records in the file. The only explaination I know is that I'm moving the file while the other application is trying to write to it. The rename-move call is very quick, though. I've tried recreating the problem, but if I'm writing to a file from one process, it won't let me move it. Has anyone else had this problem? If so, how did you solve it? Thanks! Barry Etter
-
I'm writing a very simple VB .NET application that "monitors" a remote directory (via UNC paths) for a particular data file. The data file is created by a third-party program that creates or appends comma-delimited records to the file. (I think it opens the file, writes the record and then closes the file). My application "wakes up" every few seconds and if this remote file exists, it does the following: 1) Rename the file on the remote directory to minimize possible conflicts. 2) Move the renamed file to the local PC. 3) Process the records in the local file. 4) Delete local file. Pretty simple, I know. But for some reason, I'm getting random "corrupted" records in the file. The only explaination I know is that I'm moving the file while the other application is trying to write to it. The rename-move call is very quick, though. I've tried recreating the problem, but if I'm writing to a file from one process, it won't let me move it. Has anyone else had this problem? If so, how did you solve it? Thanks! Barry Etter
Is it possible that the third-party program is itself just occasionally writing "corrupted" records in the file? Is it possible it has nothing to do with your app?
-
I'm writing a very simple VB .NET application that "monitors" a remote directory (via UNC paths) for a particular data file. The data file is created by a third-party program that creates or appends comma-delimited records to the file. (I think it opens the file, writes the record and then closes the file). My application "wakes up" every few seconds and if this remote file exists, it does the following: 1) Rename the file on the remote directory to minimize possible conflicts. 2) Move the renamed file to the local PC. 3) Process the records in the local file. 4) Delete local file. Pretty simple, I know. But for some reason, I'm getting random "corrupted" records in the file. The only explaination I know is that I'm moving the file while the other application is trying to write to it. The rename-move call is very quick, though. I've tried recreating the problem, but if I'm writing to a file from one process, it won't let me move it. Has anyone else had this problem? If so, how did you solve it? Thanks! Barry Etter
I've seen the same thing. Is this text file that is being written to on a Novell server? I had cases where multiple machines writing to the same file at the same time would produce the problem your describing. There was no way around it because it was a problem in Client32 that wasn't fixed in the last 3 versions I saw. The problem NEVER appeared when I tested the clients in a purely Windows environment, including the server. I ended up rewriting my data collection software that ran on each machine to its information directly to an SQL server instead of writing to a text file. RageInTheMachine9532