我想從Visual C#創建SQL CLR集成函數,現在我的要求是用戶將傳遞文件夾路徑作爲參數,並且函數應該獲取所有從文件夾中獲取圖像文件,並獲取其基本屬性,如FileSize,尺寸等。但似乎SQL項目不支持System.Drawing Namespace ...因爲我在普通項目中創建了相同的函數,所以它工作正常,因爲我能夠使用System.Drawing命名空間,但在這裏我不能使用System.Drawing Namespace ..所以有沒有其他方式來獲取圖像尺寸...如何在不使用位圖或圖形對象的情況下獲取圖像角色.net
下面是我在我的正常項目中使用的代碼。
public DataTable InsertFile(string FolderPath)
{
DataTable dt = new DataTable();
DataColumn[] col = new DataColumn[] { new DataColumn("FileName", typeof(System.String)), new DataColumn("FileSize", typeof(System.Int32)), new DataColumn("FilePath", typeof(System.String)), new DataColumn("Width", typeof(System.Int32)), new DataColumn("Height", typeof(System.Int32)) };
dt.Columns.AddRange(col);
FileInfo info= null;
Bitmap bmp = null;
foreach (String s in Directory.GetFiles(FolderPath, "*.jpg"))
{
info = new FileInfo(s);
bmp = new Bitmap(s);
DataRow dr = dt.NewRow();
dr["FileName"] = Path.GetFileName(s);
dr["FileSize"] = info.Length/1024;
dr["FilePath"] = s;
dr["Width"] = bmp.Width;
dr["Height"] = bmp.Height;
dt.Rows.Add(dr);
}
return dt;
}
沒有人有任何想法如何獲得圖像維度,而無需使用System.Drawing命名空間。
你在SQL項目中遇到的錯誤/異常是什麼? – ChrFin
實際上在Sql Project中,沒有辦法導入(使用System.Drawing)命名空間..既不允許添加引用System.Drawing – Abbas