I was trying to convert a sample win form app to console application.I just stuck when am trying to convert to message format.
Here is the below original code from winform
private void PutMessage(StringBuilder message, string mediaType, string filename)
{
message.AppendFormat(messageFormat, "FileSize", videoInterrogator.GetFileSize(), Environment.NewLine);
message.AppendFormat(messageFormat, "Duration", videoInterrogator.GetDuration(), Environment.NewLine);
}
Am trying to do the same in my console application
Am calling the method from FTPDownload method so the code look like
PutMessage(file, message);
private void PutMessage(string filename, StringBuilder message)
{
VideoInterrogator videoInterrogator = new VideoInterrogator();
videoInterrogator.LoadFile(filename);
message.AppendFormat(format, "FileSize", videoInterrogator.GetFileSize(), Environment.NewLine);
message.AppendFormat(format, "Duration", videoInterrogator.GetDuration(), Environment.NewLine);
}
Any help please how can i call this method pass the file name and return the values.It throws exception at “Format” am not sure what am missing here.
You’re missing a variable
format. It must have been a field in your WinForms code. Either add it to the method as a local variable, or a field to the class containingPutMessage.EDIT: I think I’m just not sure what the actual problem is. Is it the missing variable or does the format string have more or less than 3 curly-brace arguments?