altimofejevs
asked on
VB.NET VS2010. Need help with streamreader. Reading all files in the folder one by one.
Hi i need a streamreader to check all the files in the folder. The ones that are let's say TXT and RTF he has to read them one by one and put all the text from each file into one TXT. So basically it will marge all those txt, rtf files.
Thanks.
Thanks.
ASKER
FTP is not too important i can download files to the local computer. What I'm interested in is how to read those files one by one.
You will first need to download all files from FTP and then read these files and merge the files in one file and after that upload the result file on FTP.
So basically you will have to perform following steps.
1. Download files from FTP.
2. Read Files content (StreamReader)
3. Write Files content in a file (using StreamWriter)
4. Upload File on FTP (if Required)
For step 1 and 4, kindly have a look on here.
So basically you will have to perform following steps.
1. Download files from FTP.
2. Read Files content (StreamReader)
3. Write Files content in a file (using StreamWriter)
4. Upload File on FTP (if Required)
For step 1 and 4, kindly have a look on here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
RTF files are formatted text. So what you can do is this
Dim RTF As New RichTextBox
Dim RTFFiles As String() = IO.Directory.GetFiles("pat h", "*.rtf")
For Each File in RTFFiles
RTF.RTF = IO.File.ReadAllText(File)
IO.File.AppendAllText("Tar getFilePat h", RTF.Text)
Next
Dim RTF As New RichTextBox
Dim RTFFiles As String() = IO.Directory.GetFiles("pat
For Each File in RTFFiles
RTF.RTF = IO.File.ReadAllText(File)
IO.File.AppendAllText("Tar
Next
ASKER
before i use readers how can i do something like:
If file-extension = ".txt" then
elseif file-extension = "rtf then
end if
If file-extension = ".txt" then
elseif file-extension = "rtf then
end if
ASKER
Also before i read a file I need to make sure that a string exists for example "SOMESTRING"
Did you try my example?
If you need to check the string content that it constains something and then want to append then you can try this code.
string[] files = System.IO.Directory.GetFiles("Path", "*.txt");
foreach (string file in files)
{
System.IO.StreamReader reader = new System.IO.StreamReader(file);
string fileContent = reader.ReadToEnd();
reader.Close();
if (fileContent.Contains("SOMETHING"))
System.IO.File.AppendAllText("destfilePath", fileContent);
}
ASKER
how to show progressbar while downloading files from the FTP server?
So it shows how many files in total are in that folder and % how much left.
Also would be good to know download speed
So it shows how many files in total are in that folder and % how much left.
Also would be good to know download speed
ASKER