473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to read the date and time when the files are uploaded (plz plz help)

Hi,
i'm using asp.net 1.1 for my project. I have a written a c# code where the user can upload his files through the file upload component which gets uploaded to the specified path in a local disk and these files are viewed on the user screen application using the concept of fetching files from the local drive.
I have taken a table to store these files in 1 column and in the other column i have given hyperlinks to download the files.
I have actually tried to do newsletter archiving, but the files get displayed depending on the alphabetical order which i dont want. I want them to be listed in the latest upload pattern depending on the date and time which i am not able to code efficiently.
Can anyone please please help me out with this.......please...
Here is the code i have used.....

using System.IO;

namespace FileDownLoadExample
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table Table1;
private void Page_Load(object sender, System.EventArgs e)
{
if(Request.QueryString["filename"]!= null)
{
DownLoadFile(Request.QueryString"filename"]);
}
if(!IsPostBack)
{
LoadFileInfo();
}
}

private void LoadFileInfo()
{
DirectoryInfo dir = new DirectoryInfo("c:/uploads");
FileInfo[] file_info_array = dir.GetFiles();

foreach(FileInfo file_info in file_info_array)
{
TableRow row = new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();

cell1.Text = file_info.Name;
HyperLink link = new HyperLink();
link.Text = "Download";
link.NavigateUrl ="./WebForm1.aspx?filename="+file_info.Name;
cell2.Controls.Add(link);
row.Controls.Add(cell1);
row.Controls.Add(cell2);
Table1.Controls.Add(row);
}

}

private void DownLoadFile(string filename)
{
try
{
Response.Clear();
string Filename = Request.QueryString["filename"];
string downloadPath = "c:/uploads/"+Filename;
Response.ContentType ="application/octet-stream";
Response.AddHeader("Content-Disposition","attachment; filename="+Filename);
Response.TransmitFile(downloadPath);
}
catch(HttpException err)
{
Response.Write(err.ToString());
}
}
May 20 '08 #1
2 1080
kunal pawar
297 100+
There may be property for file like created date please it and store this in Datable along with file name, this helps to sort by date
May 21 '08 #2
Plater
7,872 Expert 4TB
When a file gets uploaded, simple keep track of the DateTime.Now instance?
May 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway, everything works fine when...
0
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway,...
6
by: B | last post by:
Hi, I'm developing a web application where users can upload multiple files to the website. I'm using asp.net 2.0 with FileUpload control and can upload 1 image to the server, but I would like...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
0
by: whitemoss | last post by:
Hi All, I had written a code to read a file and insert it's contents to the database. Since I will receive 3 files every hour, so, this program should read those files and insert the contents...
0
by: leen | last post by:
hola.. i need a help...this is my coding for uploading multiple files...the problem is..i want the files that i have been upload will show in the same page but using only one text box..can anyone...
5
by: JackM | last post by:
Is there a way to use PHP to read the date of a file that is uploaded into a directory and then print out that date on another page? I'm looking to have a specific file (/texts/filename.pdf)...
4
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
1
by: jagalla | last post by:
Hi, Am Srinivas Jagalla, am getting error Date format. Whatever the format I provided in Local that is comming properly. when I uploaded in live there it isn't comming same format. ex: am...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.