Hi All!
I want to check whether a given text File is Already Opened or not. I am using Visual Basic 6.0 in the Windows XP OS.
I am using the following code. It works for .doc, .xls and .mdb. But its not working for .txt file type -
Public Function IsFileOpen(FileName As String) As Boolean
-
On Error GoTo ErrHandler
-
Open FileName For Binary Access Read Lock Read As #1
-
MsgBox Input$(LOF(1), #1)
-
Close #1
-
Exit Function
-
ErrHandler:
-
MsgBox "File is Already Opened"
-
End Function
-
Can Any body give me the solution for this?
Thanks and Regards
Vijay. R
2 1373
you could do a try, catch block to open a file with all access, like use the filestream, and set the shared propertie to fileshare.none, and if it is being used it should throw an exception
u could copy the suspected file to a specific location and then try deleting that file(performing cut operation;cut=c opy+delete)..
any open file will throw an error which u can identify,thus knowing whether the file is open or not.
this method works for almost all files like .doc,.mp3,.wav. ...
but not to text files.
text files can be deleted even while it is running(in a notepad)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Basil Fenix |
last post by:
I check data from a text file with a mdb Database using a progressbar and
changing the Caption by % to indicate to the user what is happening.The file
is large and takes quite a while. The problem though is that if the user
clicks on the form everything freezes and I get "Not Responding". It is
still doing the check because if you let it continue it finishes running.
Thanks
Basil
|
by: Eric Lilja |
last post by:
Hello, I had what I thought was normal text-file and I needed to locate a
string matching a certain pattern in that file and, if found, replace that
string. I thought this would be simple but I had problems getting my
algorithm to work and in order to help me find the solution I decided to
print each line to screen as I read them.
Then, to my surprise, I noticed that there was a space between every
character as I outputted the lines to the...
|
by: Materialised |
last post by:
Hi everyone,
What I am wanting to do, is to copy, a simple plain text file, to
another file, but omitting duplicate items.
The way I thought of doing this, involved copying all the items into a
array, and then looping through that array looking for duplicates,
removing them, and then writing to another file.
This seems a very long and drawn out way of doing this to me, and also I
|
by: RN Das |
last post by:
Hi expert,
I have a small web application in C# and ASP.Net and I want to open a file
in notepad when clicked on a linked button. Here is hander code when clicked
on the link button. It can open a process of notepad on the server , but
does not open the file in notepad. What am I doing wrong? can you show me how
to do it please? What I am doing here is : I have datagrid data and when
clicked on linkbutton (logFile), it finds the row...
|
by: emanshu |
last post by:
HI all,
I an designing an application in C++. i want to open file requested by
end user but i want to reflect an error to user if file is already
opened by some other application..
will anybody tell me that how to know that the file is already open or
closed..
any help is highly appreciated...
| |
by: Tony Girgenti |
last post by:
Hello.
I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.
Using this code to open a simple text file. If i get an error in my program
after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."
FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)
|
by: CCLeasing |
last post by:
I would like to open a text file titled (c:\logs.txt).
If the file doesn't exist i would like to create it.
if it does exist i would like to append to it.
I would like to insert a line into the end of the file.
The line is contained in the variable 'line' which is a string
variable.
once i've done this i would like to close the file.
|
by: parthaspanda22 |
last post by:
How can I get to discard the contents of a text file from a specified
offset(
say, obtained from ftell)?
Sincerely.
|
by: elnoire |
last post by:
Greetings!
I've just started learning python, so this is probably one of those
obvious questions newbies ask.
Is there any way in python to check if a text file is blank?
What I've tried to do so far is:
f = file("friends.txt", "w")
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |