I have a SQL Server 2008 database from an application which stores office file templates.
The files in the database are stored in hex format (0x504B030414000600...).
With a file signature table (https://www.garykessler.net/library/file_sigs.html), I can find out which file format it is: Microsoft Office Open XML Format Documents (OOXML, like DOCX, PPTX, XLSX ...).
How can I export/convert these hex strings into the original files?
Maybe with C# ...
With the application itself, I can only export 1 file at a time. It would take days to do this with all files (about 1000).
Thank you
Export column with files from SQL Server to single file (it may be very large, but it shouldn't matter). You can for example right click and export results to CSV file.
Write simple C# console application:
use CSV parser to loop over data
inside loop you can make simple if statements to determine document file format
in every iteration convert hex format to blob file and save it somewhere on your drive
I want to copy a selected column from one excel file and paste that column to other excel file using c#
Use this free library. It's very simple to open and create xslx files! (not "free" but LGPL)
I'm new to SSIS and in one of my project I need to read both comma separated file (.csv) and tab separated file (.txt) by a single Flat File Source. Unfortunately I cannot make .txt file content as comma separated because this is how it is generated by a separate source file providing system neither have an option to modify the file content before supply to SSIS. I'm expecting some help and support of your experience.
What is the difference between these two file format.
i found this from Here
.txt File:
This is a plain text file which can be opened using a notepad present on all desktop PCs running MS Windows any version. You can store any type of text in this file. There is no limitation of what so ever text format. Due to ease of use for end users many daily data summery providers use .txt files. These files contain data which is properly comma seperated.
.csv File: abreviation of "comma seperated values"
This is a special file extension commonly used by MS Excel. Basically this is also a plain text file but with a limitation of comma seperated values. Normally when you double click this type of file it will open in MS Excel. If you do not have MS Excel installed on your computer or you find Notepad easy to use then you also can open this file in a notepad by right clicking the file and from the menu select "Open With" and then choose notepad.
My Question :
what does means comma seperated value?
if i'm going to create .csv file using c#, does i need to write file using StreamWriter and does it need to only change the the extention to .csv?
if so do i need to change the writing string with commas?
thanx....
what does means comma seperated value?
Values separated by Comma, for example.
Name,Id,3,Address
if i'm going to create .csv file using c#, does i need to write file
using StreamWriter and does it need to only change the the extention
to .csv?
Changing extension of the file will help you in opening it in MS Excel, other than that it can be anything and you can still open it through your code (StreamReader)
if so do i need to change the writing string with commas?
Yes, separate your values with Comma, or you can use any other delimiter you like. It can be semicolon ; as well since , in some languages/cultures is used for decimal separator.
CSV is structured like this:
"value","value1,"value2"
A text file can be anything from delimited, to free form , fixed width, jagged right, etc...
CSV files can be a pain in the ass if you have commas in your data, and don't properly qualify the values.
I typically create tab delimited or pipe delimited files.
From the perspective of programming, file extensions do not make a difference. In fact you may write comma seperated values inside a txt file.
Comma seperated values indicates the values are just seperated with commas; this is helpful if you want to store some data and share it accross multiple systems (on the otherhand XML is a better option).
Assume you need to store name, age and location;
TilT,25,Germany
is a comma seperated data.
In the scope of c#, you need to add commas between your values and you may save it as a CSV file or a TXT file; it makes no difference.
Is it possible to save a csv file to a SQL Server Database table using C#?
Do need to convert the csv file to Binary format in order to do this?
Is there any other way, like saving it in text format(csv is a basically a txt file)?
I'd appreciate it if you could provide some example code.
CSV files are just text. You can create a table that has an nvarchar(max) column and store your CSV files in there.
You have another helpful C# sample for import and export of CSV file with SQL Server. Below is the link:
http://www.codeproject.com/Articles/30705/C-CSV-Import-Export
You can use the data import wizard I believe and point it at a csv file. This should create a table that matches the structure of your imported csv