Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 28th, 2009, 05:26 AM
Authorized User
 
Join Date: Jul 2008
Location: Cape Town, Western Cape, South Africa.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Refreshing Solution Explorer

hi everyone, does anyone have an idea on how to programmatically refresh the solution explorer in asp.net/c# or vb.net, i am exporting a gridview to an txt file and upload it, after that i've added the lines of code that will force the file to be downloaded to the client machine, so after uploading it can't locate and open the file because the solution explorer needs to be refreshed manually. here's my code:

DBConnection cd = new DBConnection();
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter("select requesitionid,department,vendorName from tblRequisition", cd.con);
adp.Fill(ds);
// Create the CSV file to which grid data will be exported.
string path = Server.MapPath("~/Payment.txt");
StreamWriter sw = new StreamWriter(path);
// First we will write the headers.
DataTable dt = ds.Tables[0];
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
// Now write all the rows.
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(",");
}
}
sw.Write(sw.NewLine);
}
sw.Close();

//the downloading part starts here

System.IO.FileStream fs = null;
fs = System.IO.File.Open(Server.MapPath(path), System.IO.FileMode.Open);
byte[] btFile = new byte[fs.Length];
fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
fs.Close();
Response.AddHeader("Content-disposition", "attachment; filename=" + path);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(btFile);
Response.End();

Thanks in advance.
__________________
supertedz
  #2 (permalink)  
Old November 2nd, 2009, 10:59 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

hi..
First of all, I would like to tell you that Solution Explorer is only used to create your project, nothing else and your file is getting saved on the physical drive and it will be read from that path (not solution explorer). It is actually IIS that runs your website.

What is the exact error you are getting?
__________________
Gaurav


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solution Explorer does not show designer.vb file dotnetDeveloper ASP.NET 3.5 Basics 1 December 29th, 2008 11:59 AM
Ch 14 References in Solution Explorer w/ VS 2005? cJeffreywang BOOK: Beginning VB.NET Databases 1 July 28th, 2008 01:09 PM
page not refreshing Bill Crawley ASP.NET 2.0 Basics 8 February 28th, 2007 11:39 AM
refreshing XML withour refreshing the page sasidhar79 XML 1 January 12th, 2005 05:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.