SQL to INSERT file to table
I use this snippet to add any kinds of files to my database table which has a "image" data type.
public static string ReadTextFile(string path)
{
if (System.IO.File.Exists(@path))
{
var text = System.IO.File.ReadAllText(@path);
if (!string.IsNullOrEmpty(text))
{
return text;
}
}
return null;
}
string filePath = @"C:\temp\data.txt";
var stringData = ReadTextFile(filePath);
Comments
Post a Comment