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
Sachin Kadam
NA
11
37.5k
Display uploading progress bar
Sep 9 2011 11:29 AM
Hi,
I want to show uploading process at the time of file uploading on web server, i have use following code :
private
void
btnVideoupload_Click
(
object
sender
,
RoutedEventArgs
e
)
{
OpenFileDialog
dlg
=
new
OpenFileDialog
();
dlg.Multiselect
=
false
;
dlg.Filter
=
"Video Files (*.mp4)|*.mp4|Video Files (*.mpeg)|*.mpeg| Video Files (*.wmv)|*.wmv"
;
dlg.FilterIndex
=
1
;
bool
?
retval
=
dlg.ShowDialog
();
if
(
retval
!=
null
&&
retval
==
true
)
{
txtVideoPath.Text
=
dlg.File.Name
;
strmVideo1
=
dlg.File.OpenRead
();
UploadVideo
(
dlg.File.Name
,
dlg.File.OpenRead
());
}
else
{
txtVideoPath.Text
=
"No file selected..."
;
}
}
private
void
UploadVideo
(
string
fileName
,
Stream
data
)
{
if
(
strImagePath
!=
""
)
{
UriBuilder
ub
=
new
UriBuilder
("
http://www.demosite.com/ Video_Upload.ashx"
);
ub.Query
=
string
.Format
(
"filename={0}"
,
fileName
);
WebClient
c
=
new
WebClient
();
c.OpenWriteCompleted
+=
(
sender
,
e
)
=>
{
PushVideo
(
data
,
e.Result
,
fileName
);
e.Result.Close
();
data.Close
();
};
c.OpenWriteAsync
(
ub.Uri
);
}
}
private
void
PushVideo
(
Stream
input
,
Stream
output
,
String
strFileName
)
{
byte
[]
buffer
=
new
byte
[
input.Length
];
int
bytesRead
;
while
((
bytesRead
=
input.Read
(
buffer
,
0
,
buffer.Length
))
!=
0
)
{
output.Write
(
buffer
,
0
,
bytesRead
);
}
}
Reply
Answers (
2
)
How to get full path of selected file from OpenFileDialog ?
How to import excel to datagrid in silverlight