Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by zachvaldez
at 2024-07-31 08:50:12
Point:320 Replies:15 POST_ID:828646USER_ID:11517
Topic:
Microsoft Visual Basic.Net;;
I have a folder with pdfs. Id like to get the all the file names and paths and write it on a text file.
Can you provide example?
for Example:
C:PDFs
under these are all .pdf files
Thanks
Can you provide example?
for Example:
C:PDFs
under these are all .pdf files
Thanks
Author: zachvaldez replied at 2024-08-01 13:32:52
How do you append a string to the listitem being pass
Dim file1 As New System.IO.StreamWriter(fs)
For i As Integer = 0 To ListBox2.Items.Count - 1
file1.WriteLine(a(i))
Next
Dim file1 As New System.IO.StreamWriter(fs)
For i As Integer = 0 To ListBox2.Items.Count - 1
file1.WriteLine(a(i))
Next
Author: zachvaldez replied at 2024-08-01 11:30:14
The method is perfect. Im looking for textfile not excel solution. Maybe it cna be tweaked
Accepted Solution
Expert: duncanb7 replied at 2024-08-01 11:17:36
74 points EXCELLENT
The answer is already there in the following link and no
complicated reply with some minor or major change,or without
the final exact solution with the exact code attached with fully tested
http://www.ozgrid.com/forum/showthread.php?t=69086
complicated reply with some minor or major change,or without
the final exact solution with the exact code attached with fully tested
http://www.ozgrid.com/forum/showthread.php?t=69086
Author: zachvaldez replied at 2024-08-01 11:10:34
This example copies from Listbox to Textbox
Dim fs As New FileStream("C:PKLFSourcePDF.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim a As Object() = New Object(ListBox2.Items.Count - 1) {}
ListBox2.Items.CopyTo(a, 0)
Dim file1 As New System.IO.StreamWriter(fs)
For i As Integer = 0 To ListBox2.Items.Count - 1
file1.WriteLine(a(i))
Next
However, I need to append drive path "C:" for every line. Please modify
Dim fs As New FileStream("C:PKLFSourcePDF.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim a As Object() = New Object(ListBox2.Items.Count - 1) {}
ListBox2.Items.CopyTo(a, 0)
Dim file1 As New System.IO.StreamWriter(fs)
For i As Integer = 0 To ListBox2.Items.Count - 1
file1.WriteLine(a(i))
Next
However, I need to append drive path "C:" for every line. Please modify
Assisted Solution
Expert: CodeCruiser replied at 2024-08-01 09:03:05
73 points EXCELLENT
Using streamreader to read filename?
For Each FileName As String In IO.Directory.GetFiles("Path", "*.*", SearchOptions.AllDirectories) IO.File.AppendAllText("Text file path", FileName & Environment.NewLine)NextDiagnostic.Process.Start("Text file path") 1:2:3:4:
Assisted Solution
Expert: esskayb2d replied at 2024-08-01 08:00:39
50 points EXCELLENT
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Class Program
Public Shared Sub Main(ByVal args As String())
Dim mydocpath As String = 'C:/PDFs' --Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Dim sb As New StringBuilder()
For Each txtName As String In Directory.EnumerateFiles(mydocpath, "*.pdf")
Using sr As New StreamReader(txtName)
sb.AppendLine(txtName.ToString())
sb.AppendLine("= = = = = =")
sb.Append(sr.ReadToEnd())
sb.AppendLine()
sb.AppendLine()
End Using
Next
Using outfile As New StreamWriter(mydocpath & "AllPDFFiles.txt")
outfile.Write(sb.ToString())
End Using
End Sub
End Class
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Class Program
Public Shared Sub Main(ByVal args As String())
Dim mydocpath As String = 'C:/PDFs' --Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Dim sb As New StringBuilder()
For Each txtName As String In Directory.EnumerateFiles(mydocpath, "*.pdf")
Using sr As New StreamReader(txtName)
sb.AppendLine(txtName.ToString())
sb.AppendLine("= = = = = =")
sb.Append(sr.ReadToEnd())
sb.AppendLine()
sb.AppendLine()
End Using
Next
Using outfile As New StreamWriter(mydocpath & "AllPDFFiles.txt")
outfile.Write(sb.ToString())
End Using
End Sub
End Class
Expert: esskayb2d replied at 2024-08-01 07:59:59
thats wher you add the save to txt code i gave you earlier
Author: zachvaldez replied at 2024-08-01 07:04:48
he link shows this code..
Dim di As New IO.DirectoryInfo("c:")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
'list the names of all files in the specified directory
For Each dra In diar1
ListBox1.Items.Add(dra)>>>>> instead of this I prefer to write it in notepad and save as .txt
Next
Dim di As New IO.DirectoryInfo("c:")
Dim diar1 As IO.FileInfo() = di.GetFiles()
Dim dra As IO.FileInfo
'list the names of all files in the specified directory
For Each dra In diar1
ListBox1.Items.Add(dra)>>>>> instead of this I prefer to write it in notepad and save as .txt
Next
Assisted Solution
Expert: esskayb2d replied at 2024-07-31 15:03:24
50 points EXCELLENT
here you go.
http://www.developerfusion.com/code/3681/list-files-in-a-directory/
use the save code i gave you earlier to save it to a text file
http://www.developerfusion.com/code/3681/list-files-in-a-directory/
use the save code i gave you earlier to save it to a text file
Expert: esskayb2d replied at 2024-07-31 15:01:50
so, you want to copy all filenames in a folder to a file
Author: zachvaldez replied at 2024-07-31 14:36:28
What Im looking for is code that would copy a folder's content to a
text file.
text file.
Author: zachvaldez replied at 2024-07-31 13:42:44
I scanned the Microsoft page and what it does is using streamwriter/reader object that passes
data from a form to a text.
BUt what I'd like to do is read a diretory folder say C:PDF files and list all the pdf files in a text file preferably notepad
data from a form to a text.
BUt what I'd like to do is read a diretory folder say C:PDF files and list all the pdf files in a text file preferably notepad
Expert: esskayb2d replied at 2024-07-31 11:32:52
Take it from Microsoft, they wrote it
http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Author: zachvaldez replied at 2024-07-31 09:22:27
That's good link. I need to open a notepad instead of an excel file.
What do you think can be modified in the code?
What do you think can be modified in the code?
Assisted Solution
Expert: duncanb7 replied at 2024-07-31 08:53:49
73 points EXCELLENT
The code in the link is similar to your need, please take a look
http://www.ozgrid.com/forum/showthread.php?t=69086
http://www.ozgrid.com/forum/showthread.php?t=69086