TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
onais ahmer
NA
307
5.1k
How to store large txt file and covert into binary
Aug 9 2018 5:17 AM
i am trying to uploading the txt file near 1 GB
i modify the Web.config file but
<httpRuntime targetFramework="4.5" maxRequestLength="1048576"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
protected
void
Upload(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
string contentType = FileUpload1.PostedFile.ContentType;
using
(Stream fs = FileUpload1.PostedFile.InputStream)
{
using
(BinaryReader br =
new
BinaryReader(fs))
{
br.ReadBytes((Int32)fs.Length) );
// At
this
line i got the errorr msg
byte[] bytes = br.ReadBytes((Int32)fs.Length);
string constr = ConfigurationManager.ConnectionStrings[
"myConnectionString"
].ConnectionString;
using
(SqlConnection con =
new
SqlConnection(constr))
{
string query =
"insert into Files values (@Name, @ContentType, @Data)"
;
using
(SqlCommand cmd =
new
SqlCommand(query))
{
cmd.Connection = con;
cmd.Parameters.AddWithValue(
"@Name"
, filename);
cmd.Parameters.AddWithValue(
"@ContentType"
, contentType);
cmd.Parameters.AddWithValue(
"@Data"
, bytes);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}
Reply
Answers (
8
)
communication between HMI to visual studio using Ethernet ??
avoid Duplicate records inserting