I have just found this (Win2K) ... (From command line)
 
net session /delete /y
 
This closes all connected sessions and hence all files in use from remote computers. Very helpful.
 
Myles.
 
-----Original Message-----
From: Jason Coley [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 3:43 p.m.
To: Multiple recipients of list delphi
Subject: RE: RE: RE: [DUG]: Check if file is locked?

I think this is what I need, but it doesn’t really check to see if it can rename the folder, I’ll do some tests with open files and see if the pointers path rename with the folder.

 

var

  sh: SHFILEOPSTRUCT;

 

      FillChar(sh, SizeOf(sh), 0);

      sh.wFunc:=FO_Rename;

      sh.pFrom:=PChar(edit1.Text + #0);

      sh.pTo:=PChar(edit2.Text);

      SHFileOperation(sh);

 

Jason

 

-----Original Message-----
From: Jason Coley
Sent: Monday, 18 November 2002 1:44 p.m.
To: Multiple recipients of list delphi
Subject: RE: RE: [DUG]: Check if file is locked?

 

Thanks everyone, the folder that I will be renaming is a document folder, and there may be other pc’s that have files within the folder open, so I just want to check to see if any of the files are open/locked and if so rename it after all the users have closed the documents. The idea is for our Aladdins – Word Documents addin for outlook, I am making a Automatic document linker for our AutoSave, so if a property in an outlook contact like companyname changes and the document subfolder naming scheme uses the companyname, then the folder name will automatically be changed next time a document is created using Aladdins. Keeping the filing scheme current and accurate.

 

Basically taking the folder housekeeping automatic and away from the users.

 

I’ll keep looking for an answer, there must be some way to find out.

 

Jason

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 12:44 p.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Check if file is locked?

 

I'm confused. I've been told by our Network Admin that you can't rename a locked dll, as it's the same as deleting it. Yet I've just proved I can do it!

 

I went into a DLL (policy maintenance) and started flicking round subforms, then renamed the dll while still in it, and did some updating in the policy screen, then exited policy maint without a problem. When I tried deleting the renamed file (while the dll was running - under the old name?), it said there was a sharing violation and wouldn't let me. So it knew I'd renamed a locked file. The network guy tells me the server I'm doing this on is NT4 - and he says what I'm doing CAN'T be done!

 

Jason, in regard to renaming a locked folder, if you don't find a Windows call to determine if your folder is locked (and I assume there must be one), then you could always make a copy of the folder with your new name, then try deleting the original folder. If deleting the original works, then fine, if not, then something's using it, in which case you could delete the copy you made and thereby know you shouldn't rename it. Convoluted way of doing it - better if you can find the Windows call.

 

Dave

-----Original Message-----
From: Steve Aish [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 12:25
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Check if file is locked?

Do you perchance have Windows 2000?  I have found on Win2k you can usually get away with renaming a file that someone else is using.  This is apparently not possible but works most of the time anyway.

 

Steve

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 12:00
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Check if file is locked?

FYI...this morning I had a DLL locked, which I wanted to delete. It wouldn't let me, so I renamed it successfully - even though locked. Not sure if that was because of my rights or whether renaming a locked file always works?

 

Dave

-----Original Message-----
From: Conor Boyd [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 11:54
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Check if file is locked?

Had a look after you posted last week, but couldn't find much, I'm afraid.

 

Will the OS not prevent you from renaming if files are open/locked?  If so, why not just try the rename and catch any exceptions?

 

Cheers,

 

Conor

-----Original Message-----
From: Jason Coley [mailto:[EMAIL PROTECTED]]
Sent: Monday, 18 November 2002 11:50 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Check if file is locked?

Hi all,

 

I am trying to write some code that will rename a folder, but I need to know whether I can, ie no files are open or locked by another process, user etc. So I need to know the quickest and easiest method for finding out whether its OK or not to rename the folder.

 

Does anyone have any suggestions?

 

Jason

 

 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.419 / Virus Database: 235 - Release Date: 13/11/2002

Reply via email to