Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2004, 02:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default FileInfo object

Hello,

I'm using the FileInfo object to get the last write time of the file to write on the web page. However, the date that I'm getting is 12/31/1600! My code is below:
Code:
Dim objInfo As New FileInfo(Request.Path)
Label1.Text = objInfo.LastWriteTime.ToShortDateString()
This code is defined in a class that all of the web pages inherit from. Any idea why it outputs the date as 12/31/1600?

Thanks,

Brian Mains
__________________
Brian
 
Old January 14th, 2004, 05:38 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Brian,

   The Request.Path will return something like /<folder_name>/file_name.aspx. The date being returned seems do be a dummy date returned in the event of an error, which the above code causes.

You need to put the pathe in front of what is returned.. for example

Dim objInfo As New FileInfo("c:/inetpub/wwwroot/<folder_name>" + Request.Path)

or you have to hard code the full path

c:\inetpub\wwwroot\folder\file ....

I tried both and they work.

Jim

 
Old January 14th, 2004, 05:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I'm trying to do it dynamically, because the class is being imported into every ASP.NET page (page inheritance), and so I don't want to hard code one file's path because that would be an error.

Any ideas?

Thanks.
 
Old January 14th, 2004, 09:50 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Use Server.MapPath() to get the full local path of a relative url.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
FileInfo Arrya Contains Property dpkbahuguna ASP.NET 3.5 Basics 5 November 11th, 2008 09:23 AM
FileInfo Class Path Problem kwilliams VB.NET 6 April 18th, 2007 11:14 AM
Serializing Object Graph - Assigning Object to Jag venkat.kl C# 0 August 28th, 2006 10:39 AM
Combining *.csv files sing FileInfo class mhite05 C# 0 October 25th, 2005 09:53 AM
create a Line object ,Box object in CR at Runtime? thanhnt Pro VB 6 1 May 16th, 2005 06:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.