Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm starting to develop a desktop application related projects. But I have a form where the user has to upload files related to the project, although I doubt if the files should be uploaded to the database in SQL Server or in a folder on the server,
any other ideas?
Posted
Updated 31-Jan-16 7:29am
v2
Comments
Sergey Alexandrovich Kryukov 31-Jan-16 15:27pm    
You really have to embrace separation of concerns. System.Windows.Forms is just a UI library, it has nothing to do with uploading or downloading.
The answer depends on what is your server and how it works.
—SA
Manuel Dev 31-Jan-16 16:43pm    
Yes, I'm using 3-layer architecture. But I want to know how to insert a file of a few megabytes on a field varbinary ( max ) from a form.

1 solution

The important question here is how large these files would be. Please see this study by Microsoft: To BLOB or Not To BLOB: Large Object Storage in a Database or a Filesystem?[^]
If the files in question are not larger than roughly 250kB then SQL Server wins performance-wise. If they're 1MB or larger, then the Filesystem wins performance-wise. If you'll be storing them on the Filesystem, you should do it via the SQL-Server feature of Filestreams - that way, the operations can be part of transactions:
FILESTREAM Overview[^]
Getting Started with FILESTREAM Storage[^]

Edit: Between 250kB and 1MB there's no clear "winner".
And you may also take database-backup into consideration. If you store the files on the filesystem the database backup size would probably be a lot smaller.

Edit2: CodeProject articles on using Filestreams:
site:codeproject.com filestream - Google Search[^]
 
Share this answer
 
v3
Comments
BillWoodruff 31-Jan-16 13:49pm    
+5
Sascha Lefèvre 31-Jan-16 14:39pm    
Thank you, Bill :)
Manuel Dev 31-Jan-16 14:43pm    
Thank you so much, I got it. Any examples using filestream in winforms ?
Sascha Lefèvre 31-Jan-16 14:54pm    
You're welcome!
Using Filestreams isn't related to WinForms - it would be the same for a console, WPF, or other .NET application.
There are several articles here on CodeProject on using Filestreams, take a look:
https://www.google.com/search?q=site%3Acodeproject.com+filestream&ie=utf-8&oe=utf-8
Manuel Dev 31-Jan-16 15:10pm    
I have a form where the user has to select your files to upload. So how do I apply it in my project ?

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