Dim fi As New FileInfo("myOldName.txt")
fi.MoveTo("myNewName.txt")
Friday, September 26, 2008
Calculate File Size
Imports System.IO
Private Function GetFileSize(ByVal MyFilePath As String) As Long
Private Function GetFileSize(ByVal MyFilePath As String) As Long
Dim MyFile As New FileInfo(MyFilePath)
Dim FileSize As Long = MyFile.Length
Return FileSize
End Function
Dim FileSize As Long = MyFile.Length
Return FileSize
DateTime Formats
d - Numeric day of the month without a leading zero.
dd - Numeric day of the month with a leading zero.
ddd - Abbreviated name of the day of the week.
dddd - Full name of the day of the week.
f,ff,fff,ffff,fffff,ffffff,fffffff - Fraction of a second. The more F's the higher the presision.
h - 12 Hour clock, no leading zero.
hh - 12 Hour clock with leading zero.
H - 24 Hour clock, no leading zero.
HH - 24 Hour clock with leading zero.
m - Minutes with no leading zero.
mm - Minutes with leading zero.
M - Numeric month with no leading zero.
MM - Numeric month with a leading zero.
MMM - Abbreviated name of month.
MMMM - Full month name.
s - Seconds with no leading zero.
ss - Seconds with leading zero.
t - AM/PM but only the first letter.
tt - AM/PM
y - Year with out century and leading zero.
yy - Year with out century, with leading zero.
yyyy - Year with century.
zz - Time zone off set with +/-.
String to DateTime conversion and Vice Versa
'String to DateTime
VB.Net
Dim dateString As String
dateString = "1999-09-01 21:34 PM"
Dim datetimeStamp As New DateTime
datetimeStamp = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm tt", Nothing)
C#
// String to DateTime
String MyString;
MyString = "1999-09-01 21:34 PM";
DateTime MyDateTime;
MyDateTime = new DateTime();
MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm tt", null);
VB.Net
'DateTime to String
datetimeStamp = New DateTime(1999, 9, 1, 21, 34, 0)
dateString = datetimeStamp.ToString("yyyy-MM-dd HH:mm tt")
C#
//DateTime to String
MyDateTime = new DateTime(1999, 09, 01, 21, 34, 00);
String MyString;
MyString = MyDateTime.ToString("yyyy-MM-dd HH:mm tt");
VB.Net
Dim dateString As String
dateString = "1999-09-01 21:34 PM"
Dim datetimeStamp As New DateTime
datetimeStamp = DateTime.ParseExact(dateString, "yyyy-MM-dd HH:mm tt", Nothing)
C#
// String to DateTime
String MyString;
MyString = "1999-09-01 21:34 PM";
DateTime MyDateTime;
MyDateTime = new DateTime();
MyDateTime = DateTime.ParseExact(MyString, "yyyy-MM-dd HH:mm tt", null);
VB.Net
'DateTime to String
datetimeStamp = New DateTime(1999, 9, 1, 21, 34, 0)
dateString = datetimeStamp.ToString("yyyy-MM-dd HH:mm tt")
C#
//DateTime to String
MyDateTime = new DateTime(1999, 09, 01, 21, 34, 00);
String MyString;
MyString = MyDateTime.ToString("yyyy-MM-dd HH:mm tt");
Subscribe to:
Posts (Atom)