473,395 Members | 1,653 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,395 software developers and data experts.

Changing File Date & Time

Does the framework support the changing of a files Date and Time and if so
is there sample could for which I can be directed?
Jul 21 '05 #1
2 1565
Yes, you can do this. Here is a code sample from the documentation:

Public Class Test
Public Shared Sub Main()
Try
Dim path As String = "c:\Temp\MyTest.txt"

If File.Exists(path) = False Then
File.Create(path)
Else
' Take an action that will affect the write time.
File.SetLastWriteTime(path, New DateTime(1985, 4, 3))
End If

' Get the creation time of a well-known directory.
Dim dt As DateTime = File.GetLastWriteTime(path)
Console.WriteLine("The last write time for this file was {0}.",
dt)

' Update the last write time.
File.SetLastWriteTime(path, DateTime.Now)
dt = File.GetLastWriteTime(path)
Console.WriteLine("The last write time for this file was {0}.",
dt)

Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
End Sub
End Class

Hope that helps,
Marc Bu*************@bresnan.net"msnews.microsoft.com" <dl******@acninc.com>
wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Does the framework support the changing of a files Date and Time and if so
is there sample could for which I can be directed?

Jul 21 '05 #2
Yes, you can do this. Here is a code sample from the documentation:

Public Class Test
Public Shared Sub Main()
Try
Dim path As String = "c:\Temp\MyTest.txt"

If File.Exists(path) = False Then
File.Create(path)
Else
' Take an action that will affect the write time.
File.SetLastWriteTime(path, New DateTime(1985, 4, 3))
End If

' Get the creation time of a well-known directory.
Dim dt As DateTime = File.GetLastWriteTime(path)
Console.WriteLine("The last write time for this file was {0}.",
dt)

' Update the last write time.
File.SetLastWriteTime(path, DateTime.Now)
dt = File.GetLastWriteTime(path)
Console.WriteLine("The last write time for this file was {0}.",
dt)

Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
End Sub
End Class

Hope that helps,
Marc Bu*************@bresnan.net"msnews.microsoft.com" <dl******@acninc.com>
wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Does the framework support the changing of a files Date and Time and if so
is there sample could for which I can be directed?

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: msnews.microsoft.com | last post by:
Does the framework support the changing of a files Date and Time and if so is there sample could for which I can be directed?
0
by: msnews.microsoft.com | last post by:
Does the framework support the changing of a files Date and Time and if so is there sample could for which I can be directed?
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.