Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public delegate void FileDelegate(List<string> str);

public event FileDelegate FilesCompleted;


void upload_Status(object sender, EventArgs e)
		{
			FileUpload fu = sender as FileUpload;
			if (fu.Status == FileUploadStatus.Complete)
			{
				if (uploading)
					UploadFiles();
				if (FilesCompleted != null)
				{
				if (files.Count == files.Count(q => q.Status ==  FileUploadStatus.Complete))		
              FilesCompleted(files.ToList(string));
				}

			}
}


When i Bulid the program i got below Error message
C#
FilesCompleted(files.ToList(string));

"Invalid expression term 'string'"

Please Help Me...
Posted
Updated 18-Feb-15 22:28pm
v4
Comments
Kornfeld Eliyahu Peter 17-Feb-15 4:53am    
What should files.ToString(string) do?
(It is obviously a syntax error...)
Rnshanmugavadivel 17-Feb-15 5:00am    
This is file upload process..I want to store file info in list..
[no name] 17-Feb-15 5:00am    
First u chk there have any syntax error?? :)
[no name] 17-Feb-15 5:02am    
I think you have copied the line from somewhere without understanding the things that it contains. Any key word that will be used as a parameter/value will throw you the error. Rather follow some coding standards to avoid such errors.
BillWoodruff 17-Feb-15 6:56am    
Without the necessary details how can we help you? What is the "files" collection: a custom Class you wrote (what you show does not match anything I'm familiar with in WinForms). Is this ASP.NET ? or ... ?

1 solution

Well yes - string is the type, str is the variable you show.
Try:
C#
FilesCompleted(files.ToList(str));
But it may not work: you don't show the context of the code fragment, and the code as shown won't compile - so str may not exist in the exact context you are coding.


Or, as Bill suggests:
C#
FilesCompleted(files.ToList<string>());
But that is unlikely to work either unless there is a implicit conversion from your file class to a string.

Try:
C#
FilesCompleted(files.Select(f => f.Path).ToList());
Assuming it's the file path you are interested in passing to the delegate.
 
Share this answer
 
v2
Comments
BillWoodruff 17-Feb-15 7:38am    
Don't you mean .ToList<string> ? Status.Complete is not part of any built-in syntax related to actual files in .NET ... that I could find. I suspect he's using a custom Class.
OriginalGriff 17-Feb-15 7:53am    
Probably along those lines - but I have modified my answer incorporating your inspiration for what is possibly the solution.

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