473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb.net FileDateTime function in C#?

Ron
Yes, I am trying to use the FileDateTime function from
vb.net in C#. I am just starting out in C#. Here is how
I use FileDateTime in vb.net:

Dim NewDate As DateTime
NewDate = FileDateTime("C:\SomeDir\TestFile.txt")

In C# I got this far:

DateTime NewDate;
NewDate = FileDateTime("C:\SomeDir\TestFile.txt");

FileDateTime returns the creation Date-Time of a file in
vb.net. How can I implement this functionality in C#? Is
there a using library I need to add? If there is no
FileDateTime equivalent in C#, may I ask what code to use
to retrieve File CreateDate-Time information?

Thanks,
Ron

Nov 16 '05 #1
3 6092
Ron wrote:
Yes, I am trying to use the FileDateTime function from
vb.net in C#. I am just starting out in C#. Here is how
I use FileDateTime in vb.net:

Dim NewDate As DateTime
NewDate = FileDateTime("C:\SomeDir\TestFile.txt")

In C# I got this far:

DateTime NewDate;
NewDate = FileDateTime("C:\SomeDir\TestFile.txt");

FileDateTime returns the creation Date-Time of a file in
vb.net. How can I implement this functionality in C#? Is
there a using library I need to add? If there is no
FileDateTime equivalent in C#, may I ask what code to use
to retrieve File CreateDate-Time information?

Thanks,
Ron

Hi Ron,

There is a class FileInfo in C#, which gives you the file info :)

------------------------------------------------------------------------
using Sustem.IO;// You need to add this library

FileInfo fi = new FileInfo("filename.ext");
DateTime ct = fi.CreationTime;
------------------------------------------------------------------------

For additional members/functions of FileInfo class you can lookup on
msdn, for example here:
http://msdn.microsoft.com/library/de...ClassTopic.asp
Hope it helps,
Andrey aka MuZZy


Nov 16 '05 #2
Ron
Thanks. Yes, this is very helpful. I also found this:

NewDate = File.GetCreationTime("C:\\somedir\\Test.txt");
NewDate = File.GetLastWriteTime("C:\\somedir\\Test.txt");

Is there any significant difference between File and
FileInfo?

Thanks for your help.
-----Original Message-----
Ron wrote:
Yes, I am trying to use the FileDateTime function from
vb.net in C#. I am just starting out in C#. Here is how I use FileDateTime in vb.net:

Dim NewDate As DateTime
NewDate = FileDateTime("C:\SomeDir\TestFile.txt")

In C# I got this far:

DateTime NewDate;
NewDate = FileDateTime("C:\SomeDir\TestFile.txt");

FileDateTime returns the creation Date-Time of a file in vb.net. How can I implement this functionality in C#? Is there a using library I need to add? If there is no
FileDateTime equivalent in C#, may I ask what code to use to retrieve File CreateDate-Time information?

Thanks,
Ron
Hi Ron,

There is a class FileInfo in C#, which gives you the file

info :)
---------------------------------------------------------- --------------using Sustem.IO;// You need to add this library

FileInfo fi = new FileInfo("filename.ext");
DateTime ct = fi.CreationTime;
---------------------------------------------------------- --------------
For additional members/functions of FileInfo class you can lookup onmsdn, for example here:
http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfSystemIOFileInfoClassTopic.asp

Hope it helps,
Andrey aka MuZZy


.

Nov 16 '05 #3
Ron wrote:
Thanks. Yes, this is very helpful. I also found this:

NewDate = File.GetCreationTime("C:\\somedir\\Test.txt");
NewDate = File.GetLastWriteTime("C:\\somedir\\Test.txt");

Is there any significant difference between File and
FileInfo?

Quote from MSDN Help:

The static methods of the File class perform security checks on all
methods. If you are going to reuse an object several times, consider
using the corresponding instance method of FileInfo instead, because the
security check will not always be necessary.
[/END OF QUOTE]

I guess that's about the only difference, at least among the obvious ones.
Andrey
Thanks for your help.

-----Original Message-----
Ron wrote:
Yes, I am trying to use the FileDateTime function from
vb.net in C#. I am just starting out in C#. Here is
how
I use FileDateTime in vb.net:

Dim NewDate As DateTime
NewDate = FileDateTime("C:\SomeDir\TestFile.txt")

In C# I got this far:

DateTime NewDate;
NewDate = FileDateTime("C:\SomeDir\TestFile.txt");

FileDateTime returns the creation Date-Time of a file
in
vb.net. How can I implement this functionality in C#?
Is
there a using library I need to add? If there is no
FileDateTime equivalent in C#, may I ask what code to
use
to retrieve File CreateDate-Time information?

Thanks,
Ron

Hi Ron,

There is a class FileInfo in C#, which gives you the file


info :)
----------------------------------------------------------


--------------
using Sustem.IO;// You need to add this library

FileInfo fi = new FileInfo("filename.ext");
DateTime ct = fi.CreationTime;
----------------------------------------------------------


--------------
For additional members/functions of FileInfo class you


can lookup on
msdn, for example here:
http://msdn.microsoft.com/library/default.asp?


url=/library/en-
us/cpref/html/frlrfSystemIOFileInfoClassTopic.asp

Hope it helps,
Andrey aka MuZZy

Nov 16 '05 #4

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

Similar topics

3
14906
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
2808
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
7660
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
12663
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
0
1014
by: Chris | last post by:
I have a program in VB 6 and one in VB.NET that both call the FileDateTime function. On the same file the VB 6 call returns the correct modified time, the .NET code is exactly one hour off. VB 6...
8
5077
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
3
3626
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
2
5300
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
3
5311
by: 2D Rick | last post by:
On all but one PC the function "FileDateTime" works fine, but on this one PC I get the error #Name. WHY??? On a form, in the textbox's ControlSource I typed: ="The Data for this program was...
0
7192
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
7064
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
7315
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...
0
5559
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,...
1
4991
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...
0
3158
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...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.