How can i pass a var parameter from event handler to another function
I am watching a directory and doing an event handler when file is created go to the function ReadData. So how can i pass the values of tempfilepath and fileName to ReadData function?. thanks in advance
- static void OnCreated(object source, FileSystemEventArgs e)
- {
- int P_Count = 0;
-
- Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
-
-
- SomeGlobalVariables.fileName = e.FullPath;
- SomeGlobalVariables.counter++;
-
-
- string[] fileArray = new string[SomeGlobalVariables.counter];
- for (int count = 0; count <= fileArray.Length - 1; count++)
- {
-
- fileArray[count] = SomeGlobalVariables.fileName;
- SomeGlobalVariables.filenameslist.Add(fileArray[count]);
- P_Count = P_Count + 1;
-
-
- Console.WriteLine ("Number of Files in the list = " + P_Count);
-
- foreach (var filenames in SomeGlobalVariables.filenameslist)
- {
- var fileName = filenames;
- var Name_File = Path.GetFileName(fileName);
- var tempfilepath = (@"C:\Users\" + Name_File + ".CSV");
-
-
- }
-
-
-
- }
-
- static void ReadData()
- {
-
-
-
- using (System.IO.StreamWriter tempfile = new System.IO.StreamWriter(tempfilepath))
- {
-
- System.IO.StreamReader reader = new System.IO.StreamReader(fileName);
- }}