473,404 Members | 2,187 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,404 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 1567
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.