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
Rejith Egodahewa
NA
56
0
filestreamer cannot read the uploaded file in the folder -
Nov 10 2019 9:14 PM
protected
void
btnSave_Click(
object
sender, EventArgs e) {
bool
locationChecked =
false
;
try
{
DDS_Document doc =
new
DDS_Document();
#
region
"Upload file to specific location in server"
if
(
string
.IsNullOrEmpty(fluDocument.FileName)) {
ScriptManager.RegisterStartupScript(Page,
this
.GetType(),
"alert"
,
string
.Format(
"alert('{0}');"
,
"Please select file to Upload"
),
true
);
return
;
}
if
(fluDocument.HasFile) {
string
transferfile =
""
;
transferfile = fluDocument.FileName;
fluDocument.PostedFile.SaveAs(filePath + transferfile);
}
else
{
ScriptManager.RegisterStartupScript(Page,
this
.GetType(),
"alert"
,
string
.Format(
"alert('{0}');"
,
"File Could not be Updated"
),
true
);
return
;
}#
endregion
if
(!
string
.IsNullOrEmpty(fluDocument.FileName)) {
tokens = fluDocument.PostedFile.FileName.Split(
new
string
[] {
"."
}, StringSplitOptions.None);
extention = tokens[1];
FileStream fs =
new
FileStream(filePath + fluDocument.PostedFile.FileName, FileMode.Open, FileAccess.Read, FileShare.Write);
BinaryReader br =
new
BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32) fs.Length);
br.Close();
fs.Close();
doc.DocumentContent = bytes;
#
region
"Checking extention"
if
(extention ==
"pdf"
) {
doc.ContentType =
"application/"
+ extention;
}
if
(extention ==
"jpg"
) {
doc.ContentType =
"image/"
+ extention;
}
if
(extention ==
"xls"
) {
doc.ContentType =
"application/vnd.ms-excel"
;
}
if
(extention ==
"xlsx"
) {
doc.ContentType =
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
;
}
if
(extention ==
"docx"
) {
doc.ContentType =
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
;
}
if
(extention ==
"doc"
) {
doc.ContentType =
"application/doc"
;
}#
endregion
if
(File.Exists(filePath + fluDocument.PostedFile.FileName)) {
File.Delete(filePath + fluDocument.PostedFile.FileName);
}
}
If the segment in Pink is commented the program will route thru the doc object and saves the captured information in a table except the uploaded file.
Reply
Answers (
1
)
Compare two textbox value
make another party receive a form for endorsemen