Question: I have a VB6 program that someone recently helped me convert to VB.NET

In the program, when saving files, I stamp them with the date which I was getting by calling the Today() function. 

When I try to run the new VB.NET code in Vista it throws a permission exception for the Today() . If I run Visual Studio Express (this is the 2008 Express version) in Admin mode, then the problem doesn't occur, but clearly I want to end up with a stand-alone program which runs for all users without fancy permissions.

So how can a normal VB.NET program in Vista get today's date?

Answer: 
Use `DateTime.Now` or `DateTime.Today`. These are entirely managed and shouldn't throw security exceptions.

The old VB6 functions, such as `Len()`, `Left()`, `Right()`, `OpenFile()`, `FreeFile()` are all present in the .NET Framework in the Microsoft.VisualBasic DLL. To maintain backwards compatibility, they all call the old functions in unmanaged code. Unmanaged code requires special security permissions because it can be dangerous.

Whenever possible, try and use the newer .NET functions. They are usually much faster (File IO using Streams for instance) and safer.
When I try the following statement:

```
Dim result As String = Today()

```

It gives me today's date, as I'd expect, and I'm running VB2005 on Vista. Can you modify the question with the version of VB you're using? Also, can you try the following statement instead of `Today()` to see it works for you without the exception?

```
Dim result As String = Now()

```