473,320 Members | 1,820 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,320 software developers and data experts.

Deleting a file


I get the exception System.UnauthorizedAccessException: Access to the path "c:\Some.dll" is denied. when trying to delete a file

I am loading the dll with Assembly.Load(...) then using Invoke to call some code in one of the public static methods of a type

After this I need to delete the file but get the exception.

How can I release the hold on the file so I can delete it

Thank you
Nov 15 '05 #1
3 1406
Hi Sid,

IIRC that is not the exception it's rise when you try to delete an open
file, it said something about the file is in use by other process.
I think that your problem is other, maybe you do not have permission to
delete the file , or maybe you are running your application from a network
path.
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Sid Sidney" <an*******@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...


I get the exception System.UnauthorizedAccessException: Access to the path "c:\Some.dll" is denied. when trying to delete a file.
I am loading the dll with Assembly.Load(...) then using Invoke to call some code in one of the public static methods of a type.
After this I need to delete the file but get the exception.

How can I release the hold on the file so I can delete it?

Thank you.

Nov 15 '05 #2
In order to release the file, you need to unload the assembly. In order to
do that, load the assembly into a separate AppDomain and then unload the
domain before you delete the file.

Alternatively, you could turn on shadow copying
(AppDomain.SetShadowCopyFiles). This way you can keep the (shadow copied)
assembly loaded in memory and still delete the original assembly file.

hth,
Sami
www.capehill.net


"Sid Sidney" <an*******@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...


I get the exception System.UnauthorizedAccessException: Access to the path "c:\Some.dll" is denied. when trying to delete a file.
I am loading the dll with Assembly.Load(...) then using Invoke to call some code in one of the public static methods of a type.
After this I need to delete the file but get the exception.

How can I release the hold on the file so I can delete it?

Thank you.

Nov 15 '05 #3
Thanks, Shadow Copy worked!
Nov 15 '05 #4

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

Similar topics

13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
2
by: GMK | last post by:
Dear all in my asp.net application i have a text file that is installed with my application on the server. this text file is filled with data through a web interface in my application. i need to...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
8
by: shandra | last post by:
I have a file I need to delete or truncate. I tried using the KILL command in VB6. I tried using the file.delete command in VB.net. I tried manually deleting, renaming, and copying over the...
2
by: SiouxieQ | last post by:
Hi there, I'm using the code below to try to delete a name from a list of names in a file. Unfortunately it doesn't quite do what I want it to. Instead of looking for the name in the...
5
by: Sandeep Singh Sekhon | last post by:
I am Developing a Web Application with ASP.NET 1.1 I have one project Folder which is virtual directory of IIS. In this directory, I have one Folder named Photos in which I used to Store Photos....
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
1
by: diyasher | last post by:
hello my code is in c#. i am using fileSystemWatcher class to watch event when file is deleted. event is fire when file is deleted, i want to stop deleting file, means when user want to delete...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.