Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2007, 03:14 PM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default File.Move reports file as in use

I just want to move a file after I'm done working with it.

It's a DBF File which I access using ADODB:

Code:
ADODB.Recordset rs= new ADODB.Recordset();

//Connection String = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=d:\\hotfolder\\;Exclusive=No"

rs.Open("select * from "+inputFile,DBFConnection,CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockBatchOptimistic,1);

..do stuff

rs.close();
lastSlash = inputFile.LastIndexOf("\\");
moveFile = inputFile.Substring(lastSlash+1);
File.move(inputFile,moveFile)
All my processing works, it just won't let me move the file cause it says it's in use.

Is there additional cleanup I have to do other than rs.close()?

thanks


 
Old April 25th, 2007, 07:12 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Why are you using an ADODB recordset in .net? There are far better options, and they may eliminate your problem. I would imagine that you should be able to connect to a foxpro database using the System.Data.OleDb.OleDbConnection class.

-Peter
 
Old April 26th, 2007, 10:30 AM
Authorized User
 
Join Date: Jul 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I just switched to the OleDb Class / methods (I am not mastered in C# :( ). But I'm still getting same error.

Scratch that, I have to use the dispose() method of the connection object, as opposed to just closing it.

Thanks :)

 
Old May 3rd, 2007, 07:27 AM
Authorized User
 
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

Download ProcessExplorer.exe from SysInternals, and use the Find -> Find Handle Or DLL. This will show you what is holding onto the file. If you have the file open in the IDE, this could also be a problem.

Regards,

Dominic





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display .tif file, .pdf file and .jpg file phuong171 ASP.NET 1.0 and 1.1 Basics 1 March 13th, 2007 07:29 AM
vb file for crystal reports designer sasidhar79 ASP.NET 2.0 Professional 0 February 13th, 2007 01:25 AM
Can't Move Network File peter2004 ASP.NET 1.0 and 1.1 Professional 1 September 3rd, 2006 02:34 PM
File Upload/Move surendran VB How-To 0 July 19th, 2006 04:31 AM
Move a file via code fordrs3 VB How-To 2 June 26th, 2003 01:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.