Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File sharing problems

Posted on 2004-10-22
3
Medium Priority
?
130 Views
Last Modified: 2010-05-02
Hi there,

I have two applications:

First one is written by someone else and writes to several log files, some it appends to and some it over writes. I dont know the fequency in which it writes to these, but i would say fair oftem maybe every second.

Second one is written by me and what i want to do is read these files every minutes. I am having problems where when I have one of the files open the first application reports that there is a sharing violation and that it cannot write to the file.

What i would like to know is: is there a way for me to open these files in VB without causing the other application to error and say there is a sharing violation. i have tried a couple of methods, including using the filecopy method, but have not had any luck. If anyone has any ideas that would be great.

Cheers

Mat
0
Comment
Question by:pinmj001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Assisted Solution

by:inthedark
inthedark earned 1000 total points
ID: 12387557
Point 1

If you want to open a file and let another app write to the file then you need to open like this for sequenatial read operations:

lfn = FreeFile
Open "C:\MyFolder\MyFile.log" For Input Shared As lfn

Or like this for more flexible binary (read from any point any amount) operations):

lfn = FreeFile
Open "C:\MyFolder\MyFile.log" For Binary Access Read Shared As lfn

Point 2

However, you still have a problem because the software in the other app may not have included the "Share" attribute when they are appending, writing or reading from a file.  In which case you need to ask the chap to correct his code.

For example, many people thinK that this is how you open and read a file:

lfn = FreeFile
Open "C:\MyFolder\MyFile.log" For Input As lfn ' shoddy code asking for trouble
0
 
LVL 8

Accepted Solution

by:
ampapa earned 1000 total points
ID: 12391062
pinmj001, you might try creating a copy of the file and then reading your information from the copy and then delete the copy avoiding the file share issue altogether?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question