Industry Online Support
Technical Forum
10/17/2012 7:47 AM | |
Joined: 10/3/2010 Last visit: 4/25/2024 Posts: 1552 Rating: (188) |
File names with "/" won't be accepted. An example (tested on a button, on click event): '****************************************************************************** Dim objFSO, objFSOText, objFolder, objFile, objShell Dim strDirectory, strFile, strDate Dim d, m, y d=Day(Now) m=Month(Now) y=Year(Now) strDate = y & "-" & m & "-" & d strDirectory = "C:\temp\" & strDate ' Create the File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") ' Check if folder exists If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFolder = objFSO.CreateFolder(strDirectory) End If ' Check if file exists If objFSO.FileExists(strDirectory & "\" & strDate) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFile = objFSO.CreateTextFile(strDirectory & "\" & strDate) End If Set objFolder = Nothing Set objFile = Nothing '****************************************************************************** With the above, you can create a folder with name like "2012-10-15" and/or a file with name like "2012-10-15". Using this kind of format allows better sorting results in Explorer. The above example should get you started. Brgds. |
B r g d s , |
|
This contribution was helpful to1 thankful Users |
Follow us on