473,763 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding if a file is in use

I'm writing a "Hot Directory" software package that watches for an MP3
file to be uploaded to an FTP directory. When the file has completed
uploading, it will be converted into a WAV file and imported into an
automation system.

The problem that I am having is telling if IIS (FTP) is done uploading
the file and it is no longer in use. Currently, the software just
checks the file time. If the time is older than 5 minutes, the
software converts the file. This works great for our staff with
high-speed internet connections. However, if a staff member uploads
an MP3 using a 56k line, it may take longer than 5 minutes to upload.
When the software scans the file and sees it's older than 5 minutes
and starts to convert it, the software crashes.

I've tried using the "LanManServ er" object to check if a file is open.
However, going from XP to a Windows 2000 server, it doesn't seem to
work.

I've also tried to use the Try/Catch functions. This almost works.
However, for some reason the last second of each file is clipped when
converted. It almost acts like IIS no longer reports the file in use,
but it hasn't written the last block of the MP3 file yet.

I'm wondering if there is a function or compnent that someone has that
will check if a file is in use either on a local machine, or on
another machine on the LAN.

Thanks.

-Joe Kimbler
Nov 20 '05 #1
3 1861

I don't know whether the FTP server keeps the file open or only open the
file when it writes. If it keeps openning the file, you can open the file
with NonShareMode, so you won't be able to open it until FTP close it. If
FTP closes the file in IDLE time, and reopens it when necessary.

You might have to use your old way -- to check last modify timestamp of
the file. If 5 minutes are not longer enough, you have to pick up another
value. It is still possible a file is clipped. But your program could
convert the file again when it is updated again.

However, some error handles in your program are always necessary, since
the connection between client/server could be lost when half of the file
was uploaded. You never want your app crash after that.

Lifeng
MS VB

Nov 20 '05 #2
True enough. However, the main problem with this is that the file is
"timestampe d" with the time at Creation...not when modified, unless
you know a way to access the "last modified" time? I've looked all
over and havn't found anything yet.

If I could access the "Last Modified" timestamp, I could tell the
software to only wait two minutes rather than 5 since the "last
modified" time will move with the FTP Server writing to the file.

-Joe

On Thu, 20 Nov 2003 21:06:23 GMT, no****@nospam.n et (Lifeng Lu) wrote:

You might have to use your old way -- to check last modify timestamp of
the file. If 5 minutes are not longer enough, you have to pick up another
value. It is still possible a file is clipped. But your program could
convert the file again when it is updated again.


Nov 20 '05 #3
Try System.IO.File. GetLastWriteTim e

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13804
by: Noam Dekers | last post by:
Hi all, I would like to find a word stored in a text file. Structure: I have one file named keyWords.txt that stores some key words I'm interested in finding. In addition I also have a file named textOrigin.txt in which I store the text to search in. I would like my prog to check if a certain word appears in the text and than to tell me what line it found it in (if it did...). My problem is that the script can't find the words I'm...
1
1607
by: D. Alvarado | last post by:
Hello, Does anyone have a PHP 4 one-liner (or two-liner) for extracing a file from a directory in which I know the word "footer" is guaranteed to be in the file name, I know the precise directory to search, and I am assured that at most one file will match this description. I am looking to get the complete path to this file. Thanks in advance, - Dave
13
15255
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the pattern can occur on any byte boundary in the file, so chunking through the code at 16 bytes a frame maybe a problem. The file itself isn't so large, maybe 32 kbytes is all and the need for speed is not so great, but the need for accuracy in the...
15
2776
by: Benjamin Rutt | last post by:
Are there any C tools that can find redundant #includes in a project, so as to shorten compile time? Of course, eliminating single #includes by hand and determining if the recompile fails is one option, though that is an extremely manual and time-intensive approach. Thanks, -- Benjamin
8
2015
by: Rick Strahl [MVP] | last post by:
Hi all, I'm building an app that uses the ASP.Net runtime... One problem I've run into is that pages running inside of the runtime are not finding DLLs in the GAC. In fact, if I look at the debug trace of the search path it searches the bin directory and Temporary ASP files but not the GAC. A simple example I used was trying to load System.Windows.Forms. If I add a
0
1900
by: NSF12345 | last post by:
Iv developed a small program that looks for a file over our network, and copy it to the location of another computer. Im using the "If FileExists("\\oldpc\main share\Folder\file.txt") Then" way of finding if the file exists, but i want to make it so that it tries to look for the computer, not the file. At the moment this is how i am finding and copying the file: If FileExists("\\oldpc\main share\Folder\file.txt") Then FileCopy "\\oldpc\main...
1
7541
by: me | last post by:
Hi, Im having a few issues with finding exactly which program may be accessing a certain file. Lets say I need to replace a DLL with a newer version, but I need to make sure its not being accessed. Finding out if its in use isnt a problem, but I need to find out exactly which process is using it so I can ask the user if they would like to end that process to replace the file or not.
1
1360
by: Empyrean | last post by:
I'm attempting to make my first program that involves file input, but I'm running into problems finding the .txt file. I placed the file inside the same folder as the rest of the project, but it still doesn't seem to be finding it. Am I doing something wrong? try { in = new Scanner(new File("File Reading.txt")); String test = in.nextLine();
1
1362
by: avik1612 | last post by:
Hi, I have created a program to find text files in a particular directory or folder. and to find a particular word in that files i finding it difficult to put the list in an array and finding the words I have pasted the code below
9
2152
by: richee | last post by:
Hi all, I am new to Perl but see that it offers some fantastic opportunities and am trying to use it more in problem solving but could do with a little help on a problem thats driving me nuts.... I am trying to remove certain sub headers from email, i want it to tick through the text until it reaches "content-disposition:" then delete the next two lines. The ticking through part is no problem but i cant seem to do anything to the file...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
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...
1
9937
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,...
0
9822
tracyyun
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...
0
8821
agi2029
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...
1
7366
isladogs
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...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.