Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;
using System.Data.Sql;
using System.Media;



namespace PDF_Files
{
    public partial class DownloadFile : System.Web.UI.Page
    {

        File myFile = null;
        protected void Page_Load(object sender, EventArgs e)
        {

            Response.ContentType = "application/x-uknown";
            Response.AppendHeader("Content - Disposiotion", "atachment;filename=\"" + myFile.OriginalName + "\"");
            if (myFile != null)
            {
                Response.BinaryWrite(myFile.FileData);
            }
            else
            {
                Response.WriteFile(Path.Combine(AppConfiguration.UploadFolder, myFile.FileUrl));

            }
        }
    }
}
Posted

try this.

C#
File.Create("/path/myFile");
 
Share this answer
 
Hi,

System.IO.File is a static class and, therefore, cannot be instantiated.
See sample usage System.IO.File static class:
VB
File Class Sample



Hope this could help...

Regards,

Algem
 
Share this answer
 
Hello Friend I think You Cant Understand the Meaning of Static Class...???
there fore you try to do code like this..

please go forward through this article for static class
http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]

System.IO.File class is s Static Class you can not create a instance or object of this class you simply use that class directly..

http://msdn.microsoft.com/en-us/library/system.io.file.aspx[^]
 
Share this answer
 
System.IO.File is a static class and, therefore, cannot be instantiated. It is purely there to expose static utility methods.

I believe I have found , through a bit of googling, the class your code epects:

http://www.koders.com/csharp/fid953EC479AC0595720C6E56AF97A0F8AD2F75AA9A.aspx?s=file

An alternative might be to use the System.IO.FileInfo class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900