Click here to Skip to main content
16,007,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: remote file copping problem Pin
musefan31-Mar-09 3:14
musefan31-Mar-09 3:14 
JokeRe: remote file copping problem Pin
Luc Pattyn31-Mar-09 5:03
sitebuilderLuc Pattyn31-Mar-09 5:03 
JokeRe: remote file copping problem Pin
musefan31-Mar-09 5:07
musefan31-Mar-09 5:07 
GeneralRe: remote file copping problem Pin
Colin Angus Mackay31-Mar-09 4:37
Colin Angus Mackay31-Mar-09 4:37 
GeneralRe: remote file copping problem Pin
DaveyM6931-Mar-09 4:37
professionalDaveyM6931-Mar-09 4:37 
Questionhow can i convert audio sample rate and audio sample size of wave files ?? Pin
ahmedhassan9631-Mar-09 1:26
ahmedhassan9631-Mar-09 1:26 
AnswerRe: how can i convert audio sample rate and audio sample size of wave files ?? Pin
musefan31-Mar-09 2:10
musefan31-Mar-09 2:10 
Questionchecked file download from gridview Pin
grkrishna31-Mar-09 1:17
grkrishna31-Mar-09 1:17 
i have one gridview the source code of gridview is given below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" >

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="check" runat="server" Checked="false" />
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField DataField="title" HeaderText="title" />
<asp:BoundField DataField ="firstname" HeaderText="firstname" />
<asp:BoundField DataField ="lastname" HeaderText="lastname" />
<asp:BoundField DataField ="jobtitle" HeaderText="jobtitle" />
<asp:BoundField DataField ="company" HeaderText="company" />
<asp:BoundField DataField ="address1" HeaderText="address1" />
<asp:BoundField DataField ="address2" HeaderText="address2" />
<asp:BoundField DataField ="city" HeaderText="city" />
<asp:BoundField DataField ="state" HeaderText="state" />
<asp:BoundField DataField ="zipcode" HeaderText="zipcode" />
<asp:BoundField DataField ="country" HeaderText="country" />
<asp:BoundField DataField ="email" HeaderText="email" />
<asp:BoundField DataField ="phone" HeaderText="phone" />
<asp:BoundField DataField ="fax" HeaderText="fax" />
<asp:TemplateField HeaderText="requirement">
<ItemTemplate>
<asp:LinkButton ID="requirement" Text='<%#DataBinder.Eval(Container.DataItem,"requirement")%>' runat="server">
</asp:LinkButton>

<%--<asp:linkbutton id="requirement" runat="server" commandargument='<%# Eval("requirement") %>' commandname="Download">download file</asp:linkbutton>--%>
</ItemTemplate>

</asp:TemplateField>
<asp:BoundField DataField ="description" HeaderText="description" />
<asp:BoundField DataField ="find" HeaderText="find" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>

</ItemTemplate>
</asp:TemplateField>

</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>

c# code:

protected void btnDownload_click(object sender, EventArgs e)
{
foreach (GridViewRow gvr in GridView1.Rows)
{

CheckBox cb = (CheckBox)gvr.FindControl("check");
if (cb.Checked)
{
string filepath = gvr.Cells[14].Text;
DownloadFile(filepath);
}
}
}

protected void DownloadFile(string filepath)
{
System.IO.Stream iStream = null;
byte[] buffer = new byte[10000];
int length;
long dataToRead;

string filename = System.IO.Path.GetFileName(filepath);
try
{
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-Disposition", "attachment;filename=" + filename);
while (dataToRead > 0)
{
if (Response.IsClientConnected)
{
length = iStream.Read(buffer, 0, 10000);
Response.OutputStream.Write(buffer, 0, length);
Response.Flush();
buffer = new byte[10000];
dataToRead = dataToRead - length;
}
else
{
dataToRead = -1;
}
}
}
catch (Exception ex)
{
Response.Write("Error:" + ex.Message);
}
finally
{
if (iStream != null)
{
iStream.Close();
}
}
}

error message::Error:Could not find file 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\675676'.
any body give me the solution
thankyou in advance
AnswerRe: checked file download from gridview Pin
EliottA31-Mar-09 2:12
EliottA31-Mar-09 2:12 
AnswerRe: checked file download from gridview Pin
musefan31-Mar-09 2:37
musefan31-Mar-09 2:37 
GeneralRe: checked file download from gridview Pin
grkrishna31-Mar-09 21:09
grkrishna31-Mar-09 21:09 
GeneralRe: checked file download from gridview Pin
musefan31-Mar-09 21:35
musefan31-Mar-09 21:35 
QuestionValidations of Username and Password feild Pin
swapna5631-Mar-09 1:13
swapna5631-Mar-09 1:13 
AnswerRe: Validations of Username and Password feild Pin
Vinziee31-Mar-09 1:25
Vinziee31-Mar-09 1:25 
GeneralRe: Validations of Username and Password feild Pin
Henry Minute31-Mar-09 1:30
Henry Minute31-Mar-09 1:30 
AnswerRe: Validations of Username and Password feild Pin
King Julien31-Mar-09 1:38
King Julien31-Mar-09 1:38 
AnswerRe: Validations of Username and Password feild Pin
vinodkrebc31-Mar-09 2:35
vinodkrebc31-Mar-09 2:35 
QuestionFont Disposal Pin
DaveyM6931-Mar-09 1:13
professionalDaveyM6931-Mar-09 1:13 
AnswerRe: Font Disposal Pin
N a v a n e e t h31-Mar-09 2:34
N a v a n e e t h31-Mar-09 2:34 
GeneralRe: Font Disposal Pin
DaveyM6931-Mar-09 2:46
professionalDaveyM6931-Mar-09 2:46 
AnswerRe: Font Disposal Pin
Le centriste31-Mar-09 3:15
Le centriste31-Mar-09 3:15 
GeneralRe: Font Disposal Pin
DaveyM6931-Mar-09 3:31
professionalDaveyM6931-Mar-09 3:31 
QuestionReturning Random Unicode Characters Pin
Mustafa Ismail Mustafa31-Mar-09 1:00
Mustafa Ismail Mustafa31-Mar-09 1:00 
AnswerRe: Returning Random Unicode Characters Pin
Dominik Reichl31-Mar-09 1:22
Dominik Reichl31-Mar-09 1:22 
GeneralRe: Returning Random Unicode Characters Pin
Mustafa Ismail Mustafa31-Mar-09 1:37
Mustafa Ismail Mustafa31-Mar-09 1:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.