Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,178 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,999 people online right now. Registration is fast and FREE... Join Now!




visual basic express

 
Reply to this topicStart new topic

visual basic express, opening folders based on creation date

Camus
3 Oct, 2007 - 04:12 AM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 10


My Contributions
Hi all

Ive created a simple program that opens up certain folders on my local and network drives by clicking on specific buttons, it acts as a navigation menu because i spend far too long clicking around to get to the right folders.

But the way it works isn't really good enough.

The way the folders are set up on my computer is like this...We have a main customer job folder, within this folder are several subfolders that are split down by month, and then within each of these folders are a list of subfolders split down by the days date.

So the folder structure looks like this -

-----Customer Name
-------------------May 2007
-------------------------------01/05/2007
-------------------------------02/05/2007
-------------------------------03/05/2007
-------------------June 2007
-------------------------------01/06/2007
-------------------------------02/06/2007
-------------------------------03/06/2007
-------------------Jul 2007
-------------------------------01/07/2007
-------------------------------02/07/2007
-------------------------------03/07/2007


The only folder I'm ever interested in opening is the most recent date, so if it was july the 3rd, I'd want to open "customer name/july 2007/03-07-2007".

However, the program I have created only opens up the main "customer folder" because im only using basic linking, and if i linked to a more specific date, I'd constantly have to change the code each day to open the new days date.
This is the code I'm using for each button-


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Process.Start("\\IFADATAFLOW1\Avery LTD\Oct 2007\03/09/2007")

End Sub


It would be much better if i could get some code that would look within the "Customer Name" folder and then access the folder with the most recent creation date within it, this would take me to the folder for the current month, and then it would finally open the most recently created folder within that too, which would, as an end result, open up the folder for todays date, or at least the most recent date.

Is this possible? And if so how would I go about it?

I hope someone can help, this is something that has been bothering me for a while now!

I'm using visual basic express to create this program by the way.

This post has been edited by Camus: 3 Oct, 2007 - 04:28 AM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Visual Basic Express
3 Oct, 2007 - 04:29 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
First off, Visual Basic Express is VB.Net so Im moving thos topic to the appropriate forum.

Second, yes you can accomplish this, you'll need to research a few things in the System.IO Namespace:



Those will get you headed in the right direction, if, after researching those items, and writing code to solve this issue you run into problems, come and post your code with a full explanation of whats going on:

  • Whats it doing
  • Whats it supposed to be doing
  • Any errors you're encountering

And someone will be more than happy to help smile.gif
User is offlineProfile CardPM
+Quote Post

Camus
RE: Visual Basic Express
3 Oct, 2007 - 07:04 AM
Post #3

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 10


My Contributions
Hey, thanks for the reply - this is the code I am using to navigate to the main customer folder...


CODE

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Process.Start("\\IFADATAFLOW1\Avery LTD\Oct 2007\03-09-2007")

End Sub



I'll have a look at those topics you linked to, it looks a bit beyond my understanding, but I'll give it a go.
In the meantime, if anyone could show me how I could implement that into my code, that'd be great.

This post has been edited by Camus: 3 Oct, 2007 - 07:10 AM
User is offlineProfile CardPM
+Quote Post

Camus
RE: Visual Basic Express
4 Oct, 2007 - 12:47 AM
Post #4

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 10


My Contributions
I've read those help topics that you linked to Psycho...

These bits seem to be what I'm looking for -

CODE

Public Property CreationTime As DateTime

CODE

Dim instance As FileSystemInfo
Dim value As DateTime

value = instance.CreationTime

instance.CreationTime = value


I have no idea how to implement that into my code though.

At the moment I have several buttons that each open up a different folder on my network drive (the customer folder - see above post). The code I have attached to each button is this -

CODE

    Private Sub TenetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TenetButton.Click

        Process.Start("\\IFADATAFLOW1\SharedDocs\Tenet Live Work")


So that code opens the main folder i want, but what I want it to do is to access the most recently created subfolder within it and then open up the most recently created subfolder within that as a final result, so i will arrive at the folder created on todays date, or at least the most recent date. I've explained that need in a bit more detail above.

Could you give me a hand with this?


User is offlineProfile CardPM
+Quote Post

Camus
RE: Visual Basic Express
5 Oct, 2007 - 08:10 AM
Post #5

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 10


My Contributions
I've managed to get the button to open the 'Customer Folder' and then the specific month subfolder using this code...

CODE
    Dim curMonth As String = Format(Now, "MMM yyyy")

        Process.Start("\\IFADATAFLOW1\SharedDocs\Avery LTD work\" & curMonth)



So it's opening the folder for the current month provided it's filename is in the format of 'Oct 2007'.

Now I just need to find a way of getting it to open the correct days folder as well, anyone got any ideas?

It was suggested to me to look into using 'Date.Compare()', but I'm not sure how to do this.


User is offlineProfile CardPM
+Quote Post

Camus
RE: Visual Basic Express
6 Oct, 2007 - 01:55 AM
Post #6

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 10


My Contributions
I think I've sorted that problem too...I'm using this code -


CODE

        Dim curMonth As String = Format(Now, "MMM yyyy")

        Dim subDirs() As String = Dir.getdirectories
        Dim lstSubDirs As New ArrayList(subDirs)
        lstSubDirs.Sort()

        Process.Start("C:\Avery LTD\" & curMonth & "\" & lstSubDirs(lstSubDirs.Count - 1))






Now my only problem is that this line -


CODE

        Dim subDirs() As String = Dir.getdirectories


Is showing this error - 'getdirectories' is not a member of 'String'.

Can anyone explain why this is?



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:58AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month