473,569 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

15 New Member
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.......plea se...
Here is the code i have used.....

using System.IO;

namespace FileDownLoadExa mple
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Tabl e Table1;
private void Page_Load(objec t sender, System.EventArg s e)
{
if(Request.Quer yString["filename"]!= null)
{
DownLoadFile(Re quest.QueryStri ng"filename"]);
}
if(!IsPostBack)
{
LoadFileInfo();
}
}

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

foreach(FileInf o 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.NavigateUr l ="./WebForm1.aspx?f ilename="+file_ info.Name;
cell2.Controls. Add(link);
row.Controls.Ad d(cell1);
row.Controls.Ad d(cell2);
Table1.Controls .Add(row);
}

}

private void DownLoadFile(st ring filename)
{
try
{
Response.Clear( );
string Filename = Request.QuerySt ring["filename"];
string downloadPath = "c:/uploads/"+Filename;
Response.Conten tType ="applicatio n/octet-stream";
Response.AddHea der("Content-Disposition","a ttachment; filename="+File name);
Response.Transm itFile(download Path);
}
catch(HttpExcep tion err)
{
Response.Write( err.ToString()) ;
}
}
May 20 '08 #1
2 1096
kunal pawar
297 Contributor
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 Recognized Expert Expert
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
228
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 testing in my computer. However, when i uploaded the web site to my hosting space in the date/time appears as
0
267
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, everything works fine when testing in my computer. However, when i uploaded the web site to my hosting space in the date/time appears as
6
2043
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 to upload 5 images in total. Can someone help me in writing a VB.NET part on how I can upload these multiple files using the FileUpload control?
3
3079
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 =server.createobject("ADODB.connection") objConn.open "DSN=Photo" Dim sqlSELsite,ObjRSSel sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
0
30988
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 accordingly to the database and then after that, those files need to be removed to another folder. This program then will be executed again once it...
0
1700
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 help me?plz...i really need a help.. <HTML> <HEAD> <title>FILE UPLOAD</title> <body bgcolor="magenta">
5
4636
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) located in the directory and the date of its last change/modification printed into a date("F, n, Y"); format on another page. I checked the PHP manual...
4
3193
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 the StreamReader Class. Is it possible to use this class when trying to read and write to a text file located on a server? If so, could you please...
1
848
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 used .js for for Date Picker. in that I used "dd-mm-yyyy" format, same format is comming in local when I uploaded in Live server it is showing as...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.