Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have code that checks to see if Directory exist... but what I am needing is well something like this;

 

    Dim myYear As ? ' Not sure what do here  this is Psuedo COde anyway
    myYear = Year  ' What ever Year it is as of the day this code is executed
       If Directory.Exist("C:\MyMainAppDirectory\" & myYear & "\")
            ' The Directory 2005(present Year value returned) exist
            ' Code I want Here
       Else
            ' Directory 2005/Present Year-does not exist so Create Year  folder
       End If

 

The Directory its going to search for will be Named by the year BUT NOTE:

Its Name will be in this Format 2005 Not 05

So in effect it will search for the Directory called 2005

 

Any help appreciated

vbMarkO

 

P.S. As a bonus question if I might I can write the code to check if a specific file exists in a folder but how would I check if any file exist? Do I just use a WildCard or something?

Visual Basic 2008 Express Edition!
Posted
P.S. As a bonus question if I might I can write the code to check if a specific file exists in a folder but how would I check if any file exist? Do I just use a WildCard or something?

Look into the System.IO namespace

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Posted
Dim myYear as String
myYear = DateTime.Now.Year.ToString()

 

 

That worked thank you!!

 

I did the same thing with Month

 

But I have a question about Month

Right now it returns an Integer how might I get it to return

August instead of the integer 8??

 

 

I have looked through the help files and I am searching the interenet and have found lots of examples of its use as an integer but nothing else.

 

vbMarkO

Visual Basic 2008 Express Edition!
Posted
P.S. As a bonus question if I might I can write the code to check if a specific file exists in a folder but how would I check if any file exist? Do I just use a WildCard or something?

 

 

If System.IO.Directory.GetFiles("C:\Folder").Length > 0 Then
  'Files exist
End If

 

if(System.IO.Directory.GetFiles(@"C:\Folder").Length > 0)
{
  'Files exist
}

Posted

MessageBox.Show(DateTime.Now.ToString("MMMM"))

MessageBox.Show(DateTime.Now.ToString("MMM"))

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...