Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Please I want to upload an entire folder into database (SQl Server), I have made some researches on the internet but no satisfactory output. please can anyone help me and share some code if possible.

What I have tried:

haven't tried any code yet as I am yet to get any great answer
Posted
Updated 13-Mar-21 22:22pm

The simplest way is to compress the whole folder into a single ZIP file : ZipFile.CreateFromDirectory Method (System.IO.Compression) | Microsoft Docs[^] and then save that as a VARBINARY column.

But ... do bear in mind that such files will get pretty big, pretty soon - it may not be a good idea to store it directly in the DB as the DB size may get unmanageable fast, particularly when it comes to backups. It may be worth considering keeping the zips in a shared folder, and sorting the path to that file in the DB.
Depends on exactly what you are doing that this seems like a good idea, and we have no idea what that is!
 
Share this answer
 
In addition to Griff's excellent solution, if you want more functionality and are prepared to drop SQL Server and invest more time, another option would be to use ESE (Extensible Storage Engine).
This is used by Windows for Active Directory, Exchange etc.
See: extensible-storage-engine[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900