惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
A
Arctic Wolf
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
Cyberwarzone
Cyberwarzone
S
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
J
Java Code Geeks
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
I
Intezer
L
LangChain Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - Hawk_Yuan

JQGrid自動翻頁 Aspose.Words aspose.cell Aspose.Cells asp.net mvc 4 json大数据异常 提示JSON字符长度超出限制的异常[转载] 日期转换成字符串 LinkServer GridView小记 SoapHeader Credential 等等等 决心要创业成功的10个必备信念 成功人的共性 会计科目 [转]BOM分层六项原则 [转]ERP核心理念讲座系列(四) [转]ERP核心理念讲座系列(三) [转]ERP核心理念讲座系列(二) [转]ERP核心理念讲座系列(一)
C#通过SQL读写文件
Hawk_Yuan · 2021-10-22 · via 博客园 - Hawk_Yuan


int pdfMax = 0;
try
{
pdfMax = Convert.ToInt32(ConfigurationManager.AppSettings["PDFMax"]);
}
catch
{
pdfMax = 5;
}
this.openFileDialog1.Filter = "PDF檔案|*.PDF";
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.StrFile = this.openFileDialog1.FileName;
this.txtFile.Text = this.StrFile.Substring(this.StrFile.LastIndexOf('\\') + 1);
FileInfo fi = new FileInfo(this.StrFile);
FileStream fs=fi.OpenRead();
long fileLen = fs.Length;
if (fileLen > pdfMax * 1024 * 1024)
{
MessageBox.Show("上傳文件限制最大" + pdfMax + "MB");
return;
}
byte[] bytes = new byte[fileLen];
fs.Read(bytes, 0, (int)fileLen);
DataSet ds = new DataSet();
string sql = "insert into tPic values(1,@Pic)";
using (SqlConnection cn = new SqlConnection("Data Source=dev755;Initial Catalog=Test;User ID=sa;Password=liteon1234"))
{
using (SqlCommand cm = new SqlCommand(sql))
{
if (cn.State != ConnectionState.Open)
cn.Open();
cm.Connection = cn;
SqlParameter par = new SqlParameter("@Pic", SqlDbType.Image);
par.Value = bytes;
cm.Parameters.Add(par);
cm.ExecuteNonQuery();
cm.CommandText = "Select*From tPic";
cm.Parameters.Clear();
using (SqlDataAdapter sa = new SqlDataAdapter(cm))
sa.Fill(ds);
}
}

if (ds == null) return ;
if (ds.Tables.Count == 0) return ;
byte[] outs= (byte[])ds.Tables[0].Rows[0]["Pic"];
FileStream fs1 = new FileStream(@"D:\網絡訪問異常處理3.pdf", FileMode.OpenOrCreate,FileAccess.ReadWrite);
fs1.Write(outs, 0, outs.Length);
fs1.Close();
WebBrowser wb = new WebBrowser();
wb.Navigate(@"D:\網絡訪問異常處理3.pdf", true);
DirectoryInfo di = new DirectoryInfo(@"D:\");
FileInfo[] fis=di.GetFiles();
for(int i = 0; i < fis.Length; i++)
{
if (fis[i].CreationTime.ToString("yyyy-MM-dd").CompareTo(DateTime.Now.ToString("yyyy-MM-dd")) < 0)
File.Delete(fis[i].FullName);
}