Hey, im only new, so please excuse me if i do something wrong.
But im making a program where all the program does is write EVERY file and EVERY folder name into a .txt file called "KMOD! Log.txt"
The program knows what directory to list, because the user of the program must navigate into the directory then press "Dump To Log File" to dump the contents into the log
Currently the ONLY code i have is::
Private Sub Command1_Click()
Open App.Path & "\log.txt" For Output As #1
Do While Dir1.ListIndex < Dir1.ListCount - 1
MsgBox.Dir1.Dir
Dir1.ListIndex = Dir1.ListIndex + 1
Loop
Close #1
End Sub
4 1775
Hi
Sgt D Pilla
Welcome to TSDN.
You have reached the right place for knowledge shairing.
Here you will find a vast resource of related topics and code.
Feel free to post more doubts/questions in the forum.
But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.
It will help Experts in the forum in solving/underestanding your problem in a better way.
Please follow the posting guidelines in every new post/reply. please do not expect complete code from the experts of the forum. try from user side ,if u are struck up some where then ask for help.
Hey, im only new, so please excuse me if i do something wrong.
But im making a program where all the program does is write EVERY file and EVERY folder name into a .txt file called "KMOD! Log.txt"
The program knows what directory to list, because the user of the program must navigate into the directory then press "Dump To Log File" to dump the contents into the log
Currently the ONLY code i have is::
Private Sub Command1_Click()
Open App.Path & "\log.txt" For Output As #1
Do While Dir1.ListIndex < Dir1.ListCount - 1
MsgBox.Dir1.Dir
Dir1.ListIndex = Dir1.ListIndex + 1
Loop
Close #1
End Sub
In this case you mean make a Search. this way is for begginers.
It's easy to export the objects' names and types ;)
1. Form: - Option Explicit
-
-
Private Type BrowseInfo
-
hWndOwner As Long
-
pIDLRoot As Long
-
pszDisplayName As String
-
lpszTitle As String
-
ulflags As Long
-
lpfnCallback As Long
-
lParam As Long
-
iImage As Long
-
End Type
-
-
Private Const BIF_RETURNONLYFSDIRS = 1
-
Private Const MAX_PATH = 260
-
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
-
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
-
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
-
-
Public Function BrowseForFolder(ByVal hWndOwner As Long, ByVal sPrompt As String) As String
-
Dim iNull As Integer
-
Dim lpIDList As Long
-
Dim lResult As Long
-
Dim sPath As String
-
Dim udtBI As BrowseInfo
-
-
With udtBI
-
.hWndOwner = hWndOwner
-
.lpszTitle = sPrompt
-
.ulflags = BIF_RETURNONLYFSDIRS
-
End With
-
-
lpIDList = SHBrowseForFolder(udtBI)
-
If lpIDList Then
-
sPath = String$(MAX_PATH, 0)
-
lResult = SHGetPathFromIDList(lpIDList, sPath)
-
Call CoTaskMemFree(lpIDList)
-
iNull = InStr(sPath, vbNullChar)
-
If iNull Then
-
sPath = Left$(sPath, iNull - 1)
-
End If
-
End If
-
-
BrowseForFolder = sPath
-
-
-
End Function
-
Private Sub cmdBrowse_Click()
-
Dim sPath As String
-
-
txtPath.Text = ""
-
sPath = BrowseForFolder(hWnd, "choose a directory")
-
txtPath.Text = sPath
-
End Sub
-
-
Private Sub cmdDisplay_Click()
-
-
'declare variables ...
-
Dim sPath As String
-
Dim clsDirs As Collection
-
Dim udcTraverse As cTraverseDirs
-
Dim lCounter As Long
-
-
'set user difened class and collections...
-
Set clsDirs = New Collection
-
Set udcTraverse = New cTraverseDirs
-
'get the path
-
sPath = frmDirs.txtPath.Text
-
If sPath = "" Then
-
MsgBox "You must select a path"
-
Exit Sub
-
End If
-
sPath = frmDirs.txtPath.Text & "\"
-
'add it to collection ...
-
clsDirs.Add sPath
-
'initialize the counter ...
-
lCounter = 1
-
'traverse call ...
-
Call udcTraverse.TraverseDirectories(clsDirs, lCounter)
-
End Sub
-
and also it has a Class file: - Public Sub TraverseDirectories(ByVal clsDir As Collection, ByVal vCollectionCounter As Variant)
-
On Error GoTo td_error:
-
-
Dim sDirName As String, sTempPath As String, sPathToTraverse As String
-
-
-
sPathToTraverse = clsDir.Item(vCollectionCounter)
-
sDirName = Dir(sPathToTraverse, vbDirectory)
-
Do While sDirName <> "" ' Start the loop.
-
' Ignore the current directory and the encompassing directory.
-
If sDirName <> "." And sDirName <> ".." Then
-
' Use bitwise comparison to make sure sDirName is a directory.
-
If (GetAttr(sPathToTraverse & sDirName) And vbDirectory) = vbDirectory Then
-
' Display entry for directory...
-
sTempPath = sPathToTraverse & sDirName & "\"
-
clsDir.Add sTempPath
-
Else
-
'create a collection of all files ...
-
frmDirs.lstDisplay.AddItem (sPathToTraverse)
-
frmDirs.lstDisplay.AddItem (sDirName)
-
-
End If
-
End If
-
'Get next entry...
-
sDirName = Dir
-
Loop
-
vCollectionCounter = vCollectionCounter + 1
-
Call TraverseDirectories(clsDir, vCollectionCounter)
-
Exit Sub
-
td_error:
-
'break out of the loop
-
Exit Sub
-
-
End Sub
-
What does txtPath mean? and
txtPath.txt ?
is the txtPath a name of a controller ?
Acutally guys, dont worry about it.
I will do something else for my project. Its to difficult to get the program to write the name of every file in every folder in a certain directroy to a log file.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Martin Herrman |
last post by:
Dear programmers,
I have a form:
<form action=".." method="post">
<textarea name="text1"></textarea>
</form>
And a php file that saves this variable to a file:
|
by: Bob Murdoch |
last post by:
We have an asp application that creates reports from a database. The
managers would like to create the report, view the results, add a comment,
and save the report so that he can send a link to...
|
by: Aviv Ben-Yosef |
last post by:
Hello all.
I've been wondering whether or not there's a way to start writing to an
ofstream and then save it under a specific filename, or must it be done
in the first hand with fstream::open ?...
|
by: dale zhang |
last post by:
Hi,
I am trying to save and read an image from MS Access DB based on the
following article:
http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp
Right now, I saved images without any...
|
by: jad101 |
last post by:
I have an asp.net web page that:
1. Shows a message
2. Posts back (using javascript)
3. Reads contents of a file
4. response.write the contents of the file to the browser
My issue is this: ...
|
by: Yu SONG |
last post by:
Hi all,
What would be the most efficient way to save an array of floats to a
file (in text format)?
At the moment, my code looks like:
/*
* Saving an array of floats to a file
|
by: vivicio047 |
last post by:
i am writing a c prog in a Rich Text Box and want to save it. But saving the contents of the RTB also writes the font type,size and other details also as in an html file. please help me on how to...
|
by: Simon |
last post by:
I'm trying to write a little function to save data. Basically I have a
large 2d array of structs, so I'm going to have to call the save
function once per struct in the array. I'd like to save the...
|
by: dbanning |
last post by:
I am trying to save the contents of a form as a bitmap and am unsure how to do this. I can use the savepicture command to save the form as a bitmap but the contents is not intact as you would expect....
|
by: John Kotuby |
last post by:
Hi all,
I am using a 3rd party program in a VS2005 web project. The tool takes as
input a string containing HTML and converts it to RTF.
I have been creating a page by dynamically loading...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |