2
Answers

File Fetch from given Path

I done code with C#
I put .txt file in folder path and that file will modify and another txt file generated successfully I done in coding.
But how to automate or how to implement this code to user or deploy this application without any click event..
Monitoring File Path if File the exist the create new file.how to do?
i was doing run my application and creating new file.
with any Click event or run application that process need to automate.
and how to create .exe and deploy this application to user.
 
 
 
    My Code
------------------- 
try
{
using (StreamReader sr = new StreamReader("D:/Rahman/data.txt"))
{
String line = "";
while ((line = sr.ReadLine()) != null)
{
content = line;
string[] subText = new string[5];


subText[0] = content.Substring(0, 5).Trim();
subText[1] = content.Substring(8, 5).Trim();
subText[2] = content.Substring(13, 8).Trim();
subText[3] = content.Substring(21, 4).Trim();
subText[4] = content.Substring(26);//IP Address
content = subText[2] + "," + subText[0] + "," + subText[3] + ",,P10,";





//TextWriter tr = new StreamWriter("F:/Sithiq/ReadText/date1.txt");

File.AppendAllText("D:/Rahman/ModifiedData.txt", content + Environment.NewLine);




}

}

}

catch (Exception ex)
{
// MessageBox.Show(ex.ToString());
} 
Answers (2)
1
Amit Gupta

Amit Gupta

NA 16.5k 25.6k 7y
You can use FileSystemWatcher class to monitor files and whenever their is any change in the directory/file you can do your stuff there. This will work without any click event.
0
Raja T

Raja T

NA 7.4k 6k 7y
Hi mohammed, you can use WindowsService Application. Please refer below links
 
http://www.c-sharpcorner.com/UploadFile/naresh.avari/develop-and-install-a-windows-service-in-C-Sharp/
 
http://www.c-sharpcorner.com/UploadFile/8a67c0/create-and-install-windows-service-step-by-step-in-C-Sharp/