Wrox Programmer Forums
|
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 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 January 28th, 2011, 01:36 AM
Registered User
 
Join Date: Dec 2010
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Delete Files

Hello everyone, as I'm doing an academic project. I'm stuck to another problem. I'm maintaining records of some files in the database table, I need some help(rather a code) to delete files physically who doesn't have ay records in any table.... kindly help me out...
 
Old January 28th, 2011, 04:34 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You have a few options. For example you could:

Get your file names / path from the database (using ADO.NET, LINQ to SQL, Entity Framework or some other data access method) and then loop over the file names and use System.IO.File.Exists to see if the file exists.

Alternatively, you can take a look here: http://imar.spaanjaars.com/424/fun-with-linq Warning: DON'T use this with many files as the performance is bad. Just see it as a fun (ab)use of LINQ to SQL.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
ajinkyaraj78 (February 3rd, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete files without John2112 Perl 6 December 2nd, 2010 10:56 AM
How Can I Delete Cookie files. MICZ VB How-To 4 August 18th, 2007 04:56 AM
delete files in the server miguel.ossa Classic ASP Basics 1 September 5th, 2005 12:15 PM
Delete Files qazi_nomi Classic ASP Basics 7 October 18th, 2004 06:55 PM
How Can I Delete Cookie files. MICZ Pro VB 6 2 August 13th, 2004 10:44 AM





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