Here is some of the code that I have. I have a bit of a different
question now though. I was wondering if I could put a timeout event
right before it executes the DownloadFile code so that my program can
wait and make sure that the file is created to be downloaded
psi.CreateNoWindow = true;
System.Diagnostics.Process.Start(psi);
certnameLabel.Text = urlTextBox.Text;
certcityLabel.Text = cityTextBox.Text;
certstateLabel.Text = stateTextBox.Text;
certcountryLabel.Text = countryTextBox.Text;
DownloadFile(File, true);
private void DownloadFile(string fname, bool forceDownload)
{
string path = MapPath(fname);
string name = Path.GetFileName(path);
string ext = Path.GetExtension(path);
string type = "";
// set known types based on file extension
if (ext != null)
{
switch (ext.ToLower())
{
case ".pfx":
type = "application/x-pkcs12";
break;
}
}
if (forceDownload)
{
Response.AppendHeader("content-disposition",
"attachment; filename=" + name);
}
if (type != "")
Response.ContentType = type;
Response.WriteFile(path);
Response.End();
Morten Wennevik wrote:
Hi Millhouse,
I think you may need to explain in more detail.
Do you mean you have a web application with a link to a file, and the file
is created when the web application runs some program?
You can always set the link during postback, or use
Response.WriteFile/TransmitFile.
On Thu, 10 Aug 2006 22:51:40 +0200, Millhouse50 <os**********@gmail.com>
wrote:
I am wondering how I can create like a dynamic hyperlink using C#. I am
working with asp.net 2.0 and iis5 on windows 2000 server. I am creating
a file in a program that I have which needs to be downloaded at the end
of the program. Like when the program is done running the user right
clicks on the link and then checks save as and then it's on there
computer. Only thin is that the file name to be downloaded is going to
change with each run of the program. I was wondering if anyone knew
where some code was, or could give me a little sample of how to work
this. Thanks a ton for help.
--
Happy Coding!
Morten Wennevik [C# MVP]