Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Passing paramters from event handler to another function
Hesham Hassanein
Oct 7 2016 10:50 AM
409
Reply
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;
// Specify what is done when a file is created
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;
// Number of added files
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);
}}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
i can not edit update delete in gridview in asp.net c#
create ios, android,windows And web application in xamarin