Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
Passing paramters from event handler to another function
Hesham Hassanein
8y
427
1
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);
}}
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