Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Create a folder on a network drive

Posted on 2009-02-12
14
Medium Priority
?
353 Views
Last Modified: 2013-12-18
Hola Experts,
I've seen this before on here but can't seem to find it....Here's what I'm trying to do.
Need to create an agent that when clicked will look at a field (DirectoryName) and create a folder on the network with that name i.e.
Field Directory contains f:\data\newfoldername\yetanotherfoldername
Click Create Folder button and a folder is created in the background under that drive.
The data folder already exist so it would just have to the subfolder and the folder under that.
so my F drive now has a data folder with a subfolder newfoldername inside that folder I have a folder yetanotherfoldername
Thanks guys and Gals!
0
Comment
Question by:padillrr
  • 7
  • 4
  • 3
14 Comments
 
LVL 22

Accepted Solution

by:
mbonaci earned 500 total points
ID: 23628797
0
 

Assisted Solution

by:mross002
mross002 earned 500 total points
ID: 23666694
Try This code:
	'2)Create the parent folders to output data.  First check if it exists on the machine			
	Dim RootDrive As String
	RootDrive = "C:" 'Substitute this for the server root
	Dim ParentFolder As String	
	ParentFolder = "Temp"
	Dim GroupFolder As String
	GroupFolder = "ALUPurchaseOrders"
	Dim BatchFolder As String
	BatchFolder = Cstr(Format(Now(), "Medium Date"))
	
	'############ Check/Create Parent Folder ############
	TargetPath = RootDrive & "\" & ParentFolder
	If CheckCreateDirectory(TargetPath) = False Then
		Msgbox TargetPath & " does not exsit or could not be created, please specify another path.", 0 + 16, "Invalid Path"
		Exit Sub
	End If
	'############################################
	
	'############ Check/Create Group Folder ############
	TargetPath = RootDrive & "\" & ParentFolder & "\" & GroupFolder
	If CheckCreateDirectory(TargetPath) = False Then
		Msgbox TargetPath & " does not exsit or could not be created, please specify another path.", 0 + 16, "Invalid Path"
		Exit Sub
	End If
	'############################################
	
		'############ Check/Remove/Recreate Batch Folder ############
	TargetPath = RootDrive & "\" & ParentFolder & "\" & GroupFolder & "\" & BatchFolder
	If CheckIncrementCreateDirectory(TargetPath) = False Then
		Msgbox TargetPath & " does not exsit or could not be created, please specify another path.", 0 + 16, "Invalid Path"
		Exit Sub
	End If
	'############################################
 
 
 
Function CheckCreateDirectory(TargetPath As String) As Variant
	
	'Required to allow continuation
	On Error Resume Next
	
	Chdir TargetPath								'Check that the TargetPath exists
	If Err = 76 Then								'If it did not exist
		Mkdir TargetPath 							'Create the TargetPath
		Err = 0										'Reset Error Number for next check
		Chdir TargetPath 							'Verify that the TargetPath was successfully created
		If Err = 76 Then
			CheckCreateDirectory = False		'Directory was not created
		Else
			CheckCreateDirectory = True		'Directory was created
		End If
	Else
		CheckCreateDirectory = True			'Directory exists
	End If
	
	'Releases Lotus Notes' hold on the folders so they can be moved/renamed/deleted, etc...
	Chdir "C:\"
	
End Function
 
Function CheckIncrementCreateDirectory(TargetPath As String) As Variant
	
	'###############################################################
	'
	'	This code will check if the target folder exists
	'	if not, it creates it and exits
	'	if yes, then deletes it, recreates it and exits
	'
	'###############################################################
	'Required to allow continuation
	On Error Resume Next
	
	Dim BatchIndex As Integer
	Dim OriginalTargetPath As String
	OriginalTargetPath = TargetPath
	
checkagain:
	
	Chdir TargetPath								'Check that the TargetPath exists
	If Err = 76 Then								'If it did not exist
		Mkdir TargetPath 							'Create the TargetPath
		Err = 0										'Reset Error Number for next check
		Chdir TargetPath 							'Verify that the TargetPath was successfully created
		If Err = 76 Then
			CheckIncrementCreateDirectory = False		'Directory was not created
		Else
			CheckIncrementCreateDirectory = True		'Directory was created
		End If
	Else
		'directory already exists, increment to next integer and check again
		BatchIndex = BatchIndex + 1
		TargetPath = OriginalTargetPath & "[" + Cstr(BatchIndex) + "]"
		'Loop back up check again
		Goto checkagain
	End If
	
	'Releases Lotus Notes' hold on the folders so they can be moved/renamed/deleted, etc...
	Chdir "C:\"
	
End Function

Open in new window

0
 

Author Comment

by:padillrr
ID: 23672077
Line 12, 20 & 28 all error out
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:mross002
ID: 23673903
What is the error, and did you change the path to the folder on your server that you would like to store the files to.  You might also need to enable restricted operations on the agent tab.  
0
 

Author Comment

by:padillrr
ID: 23674090
Type mismatch on Targetpath is the error.
I'm trying to create folders on our fileserver \\fileserver\data
0
 

Expert Comment

by:mross002
ID: 23674501
Apologies... Dim targetpath as a global variable
Declarations:
Dim TargetPath As String
0
 

Author Comment

by:padillrr
ID: 23682384
Target path would be the field I am using to designate the actual folder name correct?!?!? I've tried everything to make this work with no luck...
0
 

Expert Comment

by:mross002
ID: 23685536
If you look at the code, TargetPath is a combination of the Root Directory, the parent folder and the sub folder that you want.  

I suspect that you are not running this agent on server.  To write to the server, you have to have the agent run on server, either by scheduling it, or using a call notesagent.runonserver.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 23690879
Check whether you can create folder manually. If not check user rights on shared folder on destination comp.
0
 

Author Comment

by:padillrr
ID: 23694093
I'm an admin, I create delete etc.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 23705708
Even if you are domain admin you still need to give yourself rights on shared folder (folder properties, sharing tab) explicitly in order to write and modify its contents.
0
 

Author Comment

by:padillrr
ID: 23766654
the folder that this folders are being created in is shared for everyone to read and write to....
0
 

Author Comment

by:padillrr
ID: 23842812
never did get this resolved but I will close it thanks for the help
0
 

Author Closing Comment

by:padillrr
ID: 31546396
thanks guys, but I was not able to get this resolved, I'll try something else later....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question