Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Reflection will not allow Delete

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nzpcmad - 09 Sep 2004 23:58 GMT
I have a C# .NET application that automatically updates software. It
downloads an update if available, gets the version numbers of the
downloaded and current files, displays these and if the user is happy,
deletes the current file and copies the downloaded one.

I get the version number of the current file via:

Version assOldVer = System.Reflection.Assembly.LoadFrom(applicationFileName).GetName().Version;

However, when I try and delete via

File.Delete (applicationFileName);

I get an error. It seems that the files is in use?

I can't find any "Close" method for the Reflection method.

Any ideas?

Many thanks
Lloyd Sheen - 10 Sep 2004 01:32 GMT
I don't have a link to the solution but it is as follows (not exactly but I
hope you get the idea).

First load the assembly into a byte array.  Then use the LoadFrom which
takes a byte array.  This way reflection does not lock the file which is
what you are seeing.

Lloyd Sheen

>I have a C# .NET application that automatically updates software. It
> downloads an update if available, gets the version numbers of the
[quoted text clipped - 17 lines]
>
> Many thanks
nzpcmad - 12 Sep 2004 22:36 GMT
Thanks for this. I couldn't find a way to load the assembly into a
byte array. You can load a byte array into an assembly. Also, wouldn't
loading the assembly (in whatever way) still leave the file "in use"?

I copied the file and then loaded the copy - which fixed my problem.

Thanks

> I don't have a link to the solution but it is as follows (not exactly but I
> hope you get the idea).
[quoted text clipped - 4 lines]
>
> Lloyd Sheen

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.