473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 "LanManServer" 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 1846

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
"timestamped" 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.net (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.GetLastWriteTime

Nov 20 '05 #4

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

Similar topics

3
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...
1
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...
13
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...
15
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...
8
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...
0
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...
1
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...
1
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...
1
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...
9
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.......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.