根据我的要求,我需要从URL获取文件.我试过了,但它总是抛出一个禁止的错误.请尝试解决此问题.请查看我的代码.
var webRequest = WebRequest.Create("https://www.fda.gov/ucm/groups/fdagov-public/@fdagov-drugs-gen/documents/document/ucm509432.pdf");
using (var response = webRequest.GetResponse())
using (var content = response.GetResponseStream())
using (var reader = new StreamReader(content))
{
var strContent = reader.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud) 我的要求我成功插入我想将最后一个增量id绑定到根文件夹文件name.id在SQL中自动递增.我想在该粗体部位上绑定最后一个递增的id.
这是我的代码请帮我解决这个问题:
string insert = "insert into Articles values('" + html+ "','" + text + "')";
try
{
con.Open();
SqlCommand cmd = new SqlCommand(insert, con);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
using (StreamWriter file = new StreamWriter(System.Web.Hosting.HostingEnvironment.MapPath(@"~\Articles\**ID**.html"), true))
{
file.WriteLine(value.editor); // Write the file.
}
return msg;
}
else
{
return msg1;
}
}
catch (Exception ex)
{
}
finally
{
con.Close();
}
Run Code Online (Sandbox Code Playgroud)