Community
Showing results for 
Search instead for 
Do you mean 
Reply

Create file folder from code?

Accepted Solution Solved
Copper Super Contributor
Posts: 478
Country: Australia
Accepted Solution

Create file folder from code?

Hi all

 

Is this possible via code?

 

I have a folder system on the C drive (stand alone machine) each client record has its own folder based on LAST NAME, FIRST NAME, in this folder everything is stored, for some of the more active clients its getting rather large and disorganised.

 

So is it possible within this folder to create sub folders using code?

 

Practical example i already have a button that creates a new opportunity, can new code be added in the button to create

 

C:/Client Files/Lastname, Firstname/New Opportunity/

 

I hope i explained myself ok?

 

Thanks


Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6

Accepted Solutions
Solution
Accepted by topic author JasonD
‎09-25-2015 03:20 AM
Nickel Contributor
Posts: 175
Country: USA

Re: Create file folder from code?

You'll need to use the System.IO namespace (https://msdn.microsoft.com/en-us/library/system.io(v=vs.100).aspx).

 

Here's a quick, untested example (VB.NET):

'Get Contact ...
'Get Names ...
'Get Opportunity name ... 'I'm presuming you can do the above portions on your own 'get the path parts Dim basePath as string = "C:/Client Files/" Dim contactPath as string = _LName & ", " & _FName & "/" '_LName and _FName are variables Dim opportunityName as string = _OpportunityName 'variable 'put the path parts together for the full path Dim fullPath as string = basePath & contactPath & opportunityName 'Check if directory exists, if not, create it If IO.Directory.Exists(fullPath)=False Then IO.Directory.CreateDirectory(fullPath) End If

View solution in original post


All Replies
Solution
Accepted by topic author JasonD
‎09-25-2015 03:20 AM
Nickel Contributor
Posts: 175
Country: USA

Re: Create file folder from code?

You'll need to use the System.IO namespace (https://msdn.microsoft.com/en-us/library/system.io(v=vs.100).aspx).

 

Here's a quick, untested example (VB.NET):

'Get Contact ...
'Get Names ...
'Get Opportunity name ... 'I'm presuming you can do the above portions on your own 'get the path parts Dim basePath as string = "C:/Client Files/" Dim contactPath as string = _LName & ", " & _FName & "/" '_LName and _FName are variables Dim opportunityName as string = _OpportunityName 'variable 'put the path parts together for the full path Dim fullPath as string = basePath & contactPath & opportunityName 'Check if directory exists, if not, create it If IO.Directory.Exists(fullPath)=False Then IO.Directory.CreateDirectory(fullPath) End If
Copper Super Contributor
Posts: 478
Country: Australia

Re: Create file folder from code?

Thanks for that knif,

 

i knew it would branch out into another space just not clue which one

 

Thanks again


Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6
Copper Super Contributor
Posts: 478
Country: Australia

Re: Create file folder from code?

Well that turned out much easier than i expected, this is the final code i got it to check if the client directory is there first in case its a new client

 

            string clast = c.LastName;
            string cfirst = c.FirstName;
            string dbase = "C:/Client Files/";

            string fullpath1 = dbase + clast + ", " + cfirst + "/" + sName;
            string fullpath2 = dbase + clast + ", " + cfirst;

           if (Directory.Exists(fullpath2))
           {
               Directory.CreateDirectory(fullpath1);
           } 
           else
           {
               Directory.CreateDirectory(fullpath2);
               Directory.CreateDirectory(fullpath1);
                      
           }


Jason Dawson Financial Planning
Brisbane | Australia - JDFP Home Page

Act Ver - Act! Premium Version 17.1.169.0, Hot Fix 3
OS - Windows 7 (stand alone machine)
MS Office - Enterprise 2007
Phone - Samsung Galaxy s6