473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# System.IO.File. Move () with "Access denied" error

To all,

I've tried to use System.IO.File. Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)
Nov 16 '05 #1
4 14769
This is a standart situation, the error message gives you whole information
of that.
The process can't access desFile because it's being used by another
process
There is just some process which is using the file someway. I am not ready
now to say what a process is it and why it holds the file but to be sure
there is one. May be you should remember the clr memory managment and check
out where that file has been accessed in your code. So to drop the object's
reference does not cause its destruction because of clr memory managment and
all resources being using by the object are held. Remeber of IDisposable
interface and its Dispose() method, may be this would be the answer.
"Jason Jacob" <50******@alumn i.cityu.edu.hk> wrote in message
news:b8******** *************** ***@posting.goo gle.com... To all,

I've tried to use System.IO.File. Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)

Nov 16 '05 #2
Download Process Explorer from

http://www.sysinternals.com

You can use that to find out which process is locking a file. You may find its not your running application but Devenv.exe or something like that.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<b8************ **************@ posting.google. com>

To all,

I've tried to use System.IO.File. Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)

Nov 16 '05 #3

I've encountered these errors when
- the file already exists in the destination directory (FileCopy
allows an overwrite, but FileMove doesn't)
- different security settings exist on the file to be moved (file
belonging to admin only...)

Regards,

Chris
Nov 16 '05 #4

I've encountered these errors when
- the file already exists in the destination directory (FileCopy
allows an overwrite, but FileMove doesn't)
- different security settings exist on the file to be moved (file
belonging to admin only...)

Regards,

Chris
Nov 16 '05 #5

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

Similar topics

1
6030
by: Riyad | last post by:
Hi all, I have trouble instantiating a COM object from an ASP file: Server.CreateObject raises "Access Denied" error. The COM object is a VB.Net assembly registered for COM Interop. It can be invoked from a standalone VBScript file without problems. I tried monitoring file system for possible access violations but unsuccessfully. The DLLs are located in a
2
6104
by: Noozer | last post by:
The following javascript code generates an "Access denied" error at the indicated line. This sample should allow the user to click "Browse" and choose a file. Once the user has selected a file the form is automatically submitted. I'm trying to avoid having seperate browse and submit actions. Can someone explain why I'm getting the error and how I can accomplish this task?
0
1696
by: Oliver | last post by:
> I am seeing an 'Access Denied' exception when using a "Server" "Serviced Component" >> ..are...registered in the GAC ? yes. >> ..are...the parameters serializable? um - parameters? - the method parameters? - yes think so - there's only one and it's a 'string' here's an example class that illustrates the problem:
0
1675
by: Jon Rista | last post by:
Hello. I'm trying to automate Excel in a C# Windows Service. This windows service has to be able to access files on network shares, so it uses a domain account on a WinNT 4.0 domain server, rather than the Local Service or Network Service, or System account. I'm running into a problem, though, with trying to instantiate Excel. When I execute the following: using Excel = Microsoft.Office.Interop.Excel; using Microsoft.Office.Core; //...
6
4135
by: ASP.Confused | last post by:
I have an ASP.NET page writtein in VB that uses ADODB. I just had to force-install MDAC 2.8 after I tried to rollback to 2.6 (my web host uses this, and I wanted to be compatible with them.) I had to manually install all of the ODBC drivers and the rest of the DLL's, and now I am getting "Access is Denied" errors on any page that uses ADODB. How do I fix it? I already gave the ODBC drivers in the folders in "c:\program files\common...
0
3532
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the original question, the subject line is: ADODB.NET and "Access Denied" I have an ASP.NET page writtein in VB that uses ADODB. I just had to
2
2740
by: Loane Sharp | last post by:
Hi there I'm using VB.NET and Office Web Components to access a SQL Server 2005 Express database and draw pictures on the fly in my ASP.NET application. Using .ExportPicture to write the GIF/JPEG/PNG image to disk and then load it into the page using the <IMG /> tag is probably not the tidiest or most secure way of doing this, but it is the easiest and allows the greatest flexibility in terms of positioning. (It also seems to be the most...
1
5131
by: srivatsans101 | last post by:
Hi, I'm trying to access the IFrame contents on a HTML page as frames.document But in IE, I'm getting Access Denied Error Message. I tried to add the IFrame's Src WebSite (a local/intranet hosted dynamic HTML page) to Trusted Sites list in IE Options.
2
5333
by: =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post by:
Yes, sorry I tried to make it clear in the original question that I want to get the user token of the service - ie. the account the service is running under. I know services don't have user tokens - I suspect users do have tokens, hence "user token", otherwise we might call them "service tokens" or somesuch :-) If you read the question again, you migh see that the fundamental question is, *assuming there is no other approach*: The...
0
8413
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
8740
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
8513
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
7352
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
6176
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
4173
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.