<p>I have a VB6 program that someone recently helped me convert to VB.NET</p>

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

<p>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.</p>

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

[{'answer_id': 64521, 'author': 'David J. Sokol', 'author_id': 1390, 'author_profile': 'https://Stackoverflow.com/users/1390', 'pm_score': 4, 'selected': True, 'text': "<p>Use <code>DateTime.Now</code> or <code>DateTime.Today</code>.  These are entirely managed and shouldn't throw security exceptions.</p>\n\n<p>The old VB6 functions, such as <code>Len()</code>, <code>Left()</code>, <code>Right()</code>, <code>OpenFile()</code>, <code>FreeFile()</code> 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.</p>\n\n<p>Whenever possible, try and use the newer .NET functions.  They are usually much faster (File IO using Streams for instance) and safer.</p>\n"}, {'answer_id': 64526, 'author': 'SqlRyan', 'author_id': 8114, 'author_profile': 'https://Stackoverflow.com/users/8114', 'pm_score': 0, 'selected': False, 'text': "<p>When I try the following statement:</p>\n\n<pre><code>Dim result As String = Today()\n</code></pre>\n\n<p>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 <code>Today()</code> to see it works for you without the exception?</p>\n\n<pre><code>Dim result As String = Now()\n</code></pre>\n"}, {'answer_id': 64600, 'author': 'Scott Dorman', 'author_id': 1559, 'author_profile': 'https://Stackoverflow.com/users/1559', 'pm_score': 0, 'selected': False, 'text': "<p>The Today() function should behave properly on Vista. I believe behind the scenes it is simply evaluating the DateTime.Today property, so it shouldn't throw any exceptions. If you're porting VB to VB.NET you should probably go ahead and use the DateTime.Today property rather than the VB6 compatability code.</p>\n"}]
['https://Stackoverflow.com/questions/64469', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8482/']