Click here to Skip to main content
15,881,380 members
Home / Discussions / C#
   

C#

 
AnswerRe: please clear this doubt Pin
Calla13-Sep-12 20:00
Calla13-Sep-12 20:00 
GeneralRe: please clear this doubt Pin
arul mozhi13-Sep-12 21:34
arul mozhi13-Sep-12 21:34 
GeneralRe: please clear this doubt Pin
Calla13-Sep-12 21:42
Calla13-Sep-12 21:42 
GeneralRe: please clear this doubt Pin
lukeer13-Sep-12 22:09
lukeer13-Sep-12 22:09 
GeneralRe: please clear this doubt Pin
BobJanova14-Sep-12 0:51
BobJanova14-Sep-12 0:51 
AnswerRe: please clear this doubt Pin
OriginalGriff13-Sep-12 21:43
mveOriginalGriff13-Sep-12 21:43 
AnswerRe: please clear this doubt Pin
Emmanuel Medina17-Sep-12 7:49
professionalEmmanuel Medina17-Sep-12 7:49 
QuestionHow to use Response.AddHeader Method Pin
ASPnoob13-Sep-12 18:59
ASPnoob13-Sep-12 18:59 
Hi all, I am trying to change the name of each file as it's being downloaded. The following are what I have done thus far:

I have uploaded files to a folder on the web server but replace their names with GUIDs to prevent problems that could arise later on due to duplication . Their original names have been saved to a database and so are their extensions and the paths to their new location on the web server. The problem I am facing now is giving them their original names back when they are downloaded.

I know I have to replace the GUID with their original names and original extension when they are being downloaded. I have looked at using Response.AddHeader() method but I am not quite sure on how to make it work. Suppose a file in a folder on the web server have the GUID 123-GtR-XYZ as its name and suppose its original name was test.doc. How do I replace the GUID with the file's original name while it is being downloaded? The following is the method I currently use to retrieve a file from the folder on the web server.

C#
//Creating a datatable
       DataTable Dtable = new DataTable("INFO");
       //Adding a column of type string name URL
       Dtable.Columns.Add("URL", typeof(string));
       Dtable.Columns.Add("Files", typeof(string));
       //putting files in an array of type string
       string[] fileEntries = Directory.GetFiles(Server.MapPath("~/Uploads/"));
       //int linkL = 0;
       foreach (string fileName in fileEntries)
       {
         Dtable.Rows.Add("~/Uploads/" + Path.GetFileName(fileName));
         //linkL++;
       }

       myGrid.DataSource = Dtable;
       myGrid.DataBind();


Let's say that I have written a SQL query to retrieve the original file name and original extension of the file being downloaded and now we have the GUID, the original file name, and original extension. How do I make use of those data to give each downloaded file it's original name back? Please give a code snippet or point me to a good tutorial if you can. Thank you in advance for your help.

modified 14-Sep-12 1:12am.

AnswerRe: How to use Response.AddHeader Method Pin
s_magus14-Sep-12 2:53
s_magus14-Sep-12 2:53 
GeneralRe: How to use Response.AddHeader Method Pin
ASPnoob14-Sep-12 3:00
ASPnoob14-Sep-12 3:00 
AnswerRe: How to use Response.AddHeader Method Pin
Pete O'Hanlon14-Sep-12 3:07
mvePete O'Hanlon14-Sep-12 3:07 
GeneralRe: How to use Response.AddHeader Method Pin
ASPnoob14-Sep-12 3:11
ASPnoob14-Sep-12 3:11 
GeneralRe: How to use Response.AddHeader Method Pin
Pete O'Hanlon14-Sep-12 3:14
mvePete O'Hanlon14-Sep-12 3:14 
QuestionWPF Datagrid Pin
abollmeyer13-Sep-12 18:02
abollmeyer13-Sep-12 18:02 
AnswerRe: WPF Datagrid Pin
abollmeyer13-Sep-12 18:15
abollmeyer13-Sep-12 18:15 
QuestionC# process question Pin
rachel_m13-Sep-12 8:13
rachel_m13-Sep-12 8:13 
AnswerRe: C# process question Pin
Wes Aday13-Sep-12 8:19
professionalWes Aday13-Sep-12 8:19 
AnswerRe: C# process question Pin
wizardzz13-Sep-12 10:03
wizardzz13-Sep-12 10:03 
GeneralRe: C# process question Pin
rachel_m13-Sep-12 10:24
rachel_m13-Sep-12 10:24 
GeneralRe: C# process question Pin
wizardzz13-Sep-12 10:28
wizardzz13-Sep-12 10:28 
GeneralRe: C# process question Pin
rachel_m13-Sep-12 11:02
rachel_m13-Sep-12 11:02 
GeneralRe: C# process question Pin
wizardzz13-Sep-12 11:47
wizardzz13-Sep-12 11:47 
AnswerRe: C# process question Pin
Alan N13-Sep-12 12:45
Alan N13-Sep-12 12:45 
GeneralRe: C# process question Pin
rachel_m14-Sep-12 6:54
rachel_m14-Sep-12 6:54 
GeneralRe: C# process question Pin
rachel_m14-Sep-12 8:09
rachel_m14-Sep-12 8:09 

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.