Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm a beginner with C# and I have to create a little program that would open a text file search for a specific string and if that string is found to move the file to a specific folder. I have many different string and folder location to move the file too.

what would be the best way to do so ?

thanks for your help

Marc

What I have tried:

I didn't try nothing yet cause I don't know where to start for this.
Posted
Updated 27-Feb-20 3:13am

1 solution

The main components you will need would probably include:
OpenFileDialog Class (System.Windows.Forms) | Microsoft Docs[^] for theuser to locate the source file. Unless it will be from a fixed location.

StreamReader Class (System.IO) | Microsoft Docs[^] to read the source text file.

File.Move Method (System.IO) | Microsoft Docs[^]
 
Share this answer
 
Comments
Maciej Los 27-Feb-20 9:26am    
Short And To The Point!
The shortest tutorial i've ever seen ;)
Richard MacCutchan 27-Feb-20 9:36am    
Hey, I can write a shorter one if you need it. :))
Maciej Los 27-Feb-20 9:42am    
:laugh:
:thumbsup:
Marc_Moi 27-Feb-20 9:42am    
Thanks for your quick response. Yes it's a fixed location my EDI software is dropping all the file in the same folder but since there's different partnership I need to send the file to the good AS2 folder to send the file. I have many files at the same time that goes to different folder. where I was working before they were using a config.ini file to enter the ID'S and the folder to send it to but I don,t know how to do that. I need to be able to add new one has I get new customer I can't redoo the programm everytime.
Richard MacCutchan 27-Feb-20 9:48am    
You should not need to redo the program if you use a settings file so you can choose where to find the files and where to store them based on application settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900